I have an Annotation like this (in Spring Boot 2):
package com.test;
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface MyAnnotation { }
And a meta annotation:
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@MyAnnotation
public @interface MyEndpoint{ }
How can I define an Aspect in order to be executed before each method that has @MyAnnotation?
If I define it has below,
@Before("execution(public * *(..)) && @annotation(myAnnotation)")
public void authorize(JoinPoint pjp, MyAnnotation myAnnotation) { }
then the method authorize
is called only
@MyAnnotation()
public myMethod(){}
and NOT in this case:
@MyEndpoint()
public myMethod() {}
thank you