I'm using AspectJ annotations instead of writing actual aspect files. I want to expose an annotation value to my advice.
I currently have this but it it doesn't expose the values inside MyAnnotation
@Before("execution(@MyAnnotation * * (..))")
public void intercept(JoinPoint jp) {
...
}
What I was thinking was somethin开发者_C百科g like this:
@Before("execution(@MyAnnotation * * (..)) && @this(MyAnnotation)")
public void intercept(JoinPoint jp, MyAnnotation myAnnotation) {
...
}
This clearly has a syntax error but was wondering if I was close. I can't seem to find an example syntax when using AspectJ annotations to do this.
You are using type, when you should be using an identifier. The correct code is:
@Before("execution(@MyAnnotation * * (..)) && @this(myAnnotation)")
public void intercept(JoinPoint jp, MyAnnotation myAnnotation) {
...
}
精彩评论