I have defined a custom annotation as below.
package com.xyz;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Loggable {
String message() default "Log Message";
}
My aspect class contains the below method:
@Around(value = "@annotation(com.xyz.Loggable)")
public void logAround(ProceedingJoinPoint joinPoint) throws Throwable {
// come code here
}
My service interface is as below.
public interface Service {
@Loggable
public void method1();
}
My implementation is as below.
public class ServiceImpl implements Service {
public void method1() {
// some code here
}
}
With this setup, My advice is not getting triggered. (however it gets triggered if i move the @Loggable annotation to method1() in ServiceImpl class).
I would like to keep the annotation defined at interface level instead of method implementations. Is there a way to get this work ?