caching - Spring custom @Cacheable annotation using @AliasFor -
i'm trying write annotation annotated @cacheable. goal add few more attributes later access when manually initializing caches. @ first glance seem similar writing custom spring @cacheable annotation, i'm trying use @aliasfor instead of going down parser route.
here's have far:
@retention(retentionpolicy.runtime) @target({elementtype.method}) @inherited @cacheable public @interface cacheablelocal { @aliasfor(annotation = cacheable.class, attribute = "value") string[] value() default {}; @aliasfor(annotation = cacheable.class, attribute = "cachenames") string[] cachenames() default {}; @aliasfor(annotation = cacheable.class, attribute = "key") string key() default ""; @aliasfor(annotation = cacheable.class, attribute = "keygenerator") string keygenerator() default ""; @aliasfor(annotation = cacheable.class, attribute = "condition") string condition() default ""; @aliasfor(annotation = cacheable.class, attribute = "unless") string unless() default ""; int maxentries() default 100; long ttlseconds() default 1800l; } and had hoped use new annotation this:
@cacheablelocal(cachenames = "dictionary", maxentries = 300, ttlseconds = 1800) public string getdefinition(string word) { ... } the problem i've run cachenames value isn't associated @cacheable meta-annotation despite presence of @aliasfor. while can see spring correctly finds @cacheable meta-annotation on @cacheablelocal annotation when synthesizing, doesn't consider values should set.
it's similar reported spring bug https://jira.spring.io/browse/spr-13475. it's not same, i'm hoping i'm doing wrong , there's easy solution other waiting spring 4.3 :)
Comments
Post a Comment