I am new to AOP, have gone through the tutorials here: https://eclipse.org/aspectj/ and have basic understanding of how aspects work.
This is what I am trying to do.
There is an @annotation called "MyAnnotation" and lets say I have a method decorated like this
@MyAnnotation
public void MyMethod() {
//something here
}
I have written an aspect class like this:
@Aspect
public class MyAspect {
@Around("@annotation(MyAnnotation)")
public void MyAdvice(ProceedingJoinPoint p) throws Throwable {
// I want to call an intereceptor here, for example
SomeInterceptor.invoke(methodInvocation)
p.proceed();
}
}
SomeInterceptor
is in a dependency package and I don't own the code. It extends the MethodInterceptor
class in org.aopalliance.intercept
. It does some processing that I need to do in my advice method before MyMethod
is called. I cannot use Guice.bindInterceptor
and is looking for a similar alternative. I am not sure how can I get the methodInvocation
object that I can pass to invoke method.
Thanks!
This is what I needed: https://github.com/eclipse/org.aspectj/tree/master/docs/sandbox/aopalliance
This is the bridge between aspectJ and AOPAlliance.