soc
soc

Reputation: 28451

How to get the value of an annotation parameter for usage in AspectJ?

Consider this method:

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

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

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

But how can I access the field rights of @Access, which stores the particular access level, so that I can work with it?

Upvotes: 5

Views: 3826

Answers (1)

Constantiner
Constantiner

Reputation: 14221

Try to use:

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

See documentation here.

Upvotes: 8

Related Questions