How to get annotation parameter value for use in AspectJ?

Consider this method:

@Access(rights = GUEST)
public void foo() {
  doSomething();
}

This pointcut basically matches if the method has an annotation @Access:

pointcut check() : 
execution(@Access * *(..));

But how can I access the field rightsfor @Access, which retains a certain level of access so that I can work with it?

+5
source share
1 answer

Try using:

pointcut check(Access access) : 
execution(@Access * *(..)) && @annotation(access);

See here .

+8
source

All Articles