开发者

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

开发者 https://www.devze.com 2023-03-21 11:17 出处:网络
Consider this method: @Access(rights = GUEST) public void foo() { doSomething(); } This pointcut basically matches if the method has an @Access annota开发者_开发百科tion:

Consider this method:

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

This pointcut basically matches if the method has an @Access annota开发者_开发百科tion:

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?


Try to use:

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

See documentation here.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号