I have below annotation.
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface MyAnnotation {
}
Actually I think we can get the value
in another way round instead of just from ProceedingJoinPoint, which will definitely require us to make use of reflection
.
Have a try as follows using annotation directly: add com.mycompany.MyAnnotation yourAnnotation
in your advice params
and @annotation(yourAnnotation)
in @Around
.
@Around("execution(public * *(..)) && @annotation(yourAnnotation)")
public Object procede(ProceedingJoinPoint pjp, com.mycompany.MyAnnotation yourAnnotation) {
...
yourAnnotation.value(); // get your annotation value directly;
...
}
com.mycompany.MyAnnotation
in advice params just work as that in
@Around("execution(public * *(..)) && @annotation(com.mycompany.MyAnnotation)")
yourAnnotation
can be valid variable name since MyAnnotation
in params already points out which annotation it should be. Here yourAnnotation
is used to retrieve the annotation instance only.
If you want to pass more params you can try args()
.
For more details, do please check its official doc. For Annotation value, you can just search @Auditable
.