I have created a java 17 repeatable annotation and want to create an aspect around the method containing the annotation is invoked. This seems to work when method is annotated once but fails to invoke when I have repeatable annotation. I am using aspectjrt version 1.9.7. Am I doing something wrong or aspect doesn't support repeatable annotations? Any workaround for the same?
Annotation class ->
@Repeatable(Schedules.class)
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Schedule {
String dayOfMonth() default "first";
String dayOfWeek() default "Mon";
int hour() default 12;
}
The repeatable class ->
@Retention(value = RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Schedules {
Schedule[] value();
}
The aspect class ->
@Aspect
@Component
@Slf4j
public class Aspect {
@Around("@annotation(Schedule)")
public Object trace(ProceedingJoinPoint joinPoint) throws Throwable {
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
Schedule filters = method.getAnnotation(Schedule.class);
//Business Logic
return joinPoint.proceed();
}
}