Aspect for method annotated with annotation which are annotated with another annotation

佐手、 提交于 2019-12-20 04:10:18

问题


Is it possible to make pointcut using Spring AOP for methods and type having annotation which was annotated with some annotation. Here's my custom annotation:

@AccessRestriction
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface HasPermission {
}

It annotated with this annotation:

@Target({ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface AccessRestriction {
}

So is it possible to create point cut which will handle all methods which are annotated with any annotation annotated with AccessRestriction.


回答1:


I found solution.

I made such pointcut:

 within(@(@test.security.access.AccessRestriction *) *) ||
 execution(@(@test.security.access.AccessRestriction *) * *(..))


来源:https://stackoverflow.com/questions/37806731/aspect-for-method-annotated-with-annotation-which-are-annotated-with-another-ann

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!