1

AopAllianceを使用したメソッドインターセプトでは、メソッドがインターセプトされたクラスからメソッドを呼び出す方法はありますか?

例えば:

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

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
     }
}

必要に応じて、詳細をお知らせします。

4

1 に答える 1

2

どうですか

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

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

于 2011-05-24T04:57:09.600 に答える