1

In method interception with AopAlliance is there a way to call a method from the class who's method was intercepted?

For example:

public class MyClass {
     public void interceptMe() {}
     public void invokeMe() {}
}

and

public class MyInterceptor implements MethodInterceptor {
     public Object invoke(MethodInvocation invocation) throws Throwable {
          // This is where MyClass.interceptMe() is intercepted
          // I would like to call MyClass.invokeMe() for the instance of the class who's method was intercepted
     }
}

I will be happy to provide more details if needed.

knpwrs
  • 15,691
  • 12
  • 62
  • 103

1 Answers1

2

How about

((MyClass)invocation.getThis()).invokeMe()

http://aopalliance.sourceforge.net/doc/org/aopalliance/intercept/MethodInvocation.html

Alex Gitelman
  • 24,429
  • 7
  • 52
  • 49