I have created a java8's repeatable annotation and want create an aspect before the method containing the annotation is invoked. This seems to work when method is annotated once but fails to invoke when I have repeatable annotation. I am using aspectjrt version 1.8.6. Looks like aspect doesn't support repeatable annotations. Any workaround?
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface MultiCacheEvicts
{
MultiCacheEvict[] value();
}
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Repeatable(MultiCacheEvicts.class)
public @interface MultiCacheEvict
{
String value();
String[] keyPrefix() default "";
}
@Aspect
public class MultiCacheEvictAdvice
{
@Before("@annotation(multiCacheEvict)")
public void cacheEvict(JoinPoint joinPoint, MultiCacheEvict
multiCacheEvict)
{
//never gets invoked when repeatable annotation present on the method
}
}
/**This works**/
@MultiCacheEvict(value = "default", keyPrefix ={"messageAttributes"})
public void purgeCache(Set<Long> userIds)
/**This doesn't works, advice never gets invoked**/
@MultiCacheEvict(value = "default", keyPrefix ={"messageAttributes"})
@MultiCacheEvict(value = "entity", keyPrefix ={"tagAttributes"})
public void purgeCache(Set<Long> userIds)