I am using spring AOP, how can I get values from annotation, Here is my annotation:
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Inherited
@Documented
public @interface ExecutionMethodProfiler
{
String value() default "defaultValue";;
}
here is my XML:
<aop:aspectj-autoproxy/>
<aop:config>
<aop:aspect ref="methodProfiler">
<aop:pointcut id="serviceMethod"
expression="(execution(* com.old..*(..)) or execution(* com.test..*(..))) and @annotation(com.test.profiler.ExecutionMethodProfiler)" />
<aop:around pointcut-ref="serviceMethod" method="profile"/>
</aop:aspect>
</aop:config>
And this is my serviceMethod:
public void profile(ProceedingJoinPoint jointPoint) throws Throwable {}
as of now I can get the values by using this code:
MethodSignature signature = (MethodSignature) jointPoint.getSignature();
System.out.println(signature.getMethod().getAnnotation(ExecutionMethodProfiler.class).value());
I don't like it, is there a better way?