简体   繁体   中英

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

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.

I found solution.

I made such pointcut:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM