Reputation: 2194
In my application I have methods annotated like this:
@SomeAnnotation(key1="value1", key2 ="value2")
public void myMethod()
I have defined the following apsect to perform some action on executing of those methods:
@Aspect
public class MyAspect()
{
@Around("@annotation(my.package.SomeAnnotation)")
public Object doSomething(final ProceedingJoinPoint pjp) throws Throwable
{
...
}
}
Now I would like to use the annotation values ("value1" and "value2" in the above example) inside my advice. What is the way to access the annotation at this point?
Upvotes: 3
Views: 2372
Reputation: 242696
@annotation
can be used in binding form, as follows:
@Around(value = "@annotation(a)", argNames = "a")
public Object doSomething(final ProceedingJoinPoint pjp, SomeAnnotation a)
throws Throwable { ... }
Upvotes: 7