I have annotation:
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
public @interface Retry {
int DEFAULT_RETRIES = 2;
int times() default DEFAULT_RETRIES;
}
Which is used either on class level:
@Retry(times = 5)
public class PersonServiceClass {
//...
public void deletePerson(long id) {
//...
}
}
Or method level (another class, not PersonServiceClass):
@Retry
public void deletePerson(long id) {
//...
}
The aspect is caught by such class:
@Aspect
@Component
public class RetryInterceptor {
@Around("@within(retry) || @annotation(retry)")
public Object around(ProceedingJoinPoint proceedingJoinPoint, Retry retry) throws Throwable {
System.out.println("around - " + retry);
System.out.println("joinpoint - " + proceedingJoinPoint);
return aroundHandler(proceedingJoinPoint, retry);
}
And aspect is correctly caught on method or class level, but there is something wrong with binding Retry
annotation.
When @Around
is as following: @Around("@within(retry) || @annotation(retry)")
then:
- When caught on method level than
retry
is binded - When caught on class level than
retry
is null.
When @Around
is as following @Around("@annotation(retry) || @within(retry)")
then:
- When caught on method level than
retry
is null. - When caught on class level than
retry
is binded.
Spring Boot Parent Version - 2.1.1.RELEASE