我创建了一个java8的可重复注释,并希望在调用包含注释的方法之前创建一个方面。这似乎在方法注释一次时起作用,但在我有可重复的注释时无法调用。我使用的是aspectjrt版本1.8.6。看起来方面不支持可重复的注释。任何解决方法?
@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)