开发者

AopAlliance (Guice): Call another method from an intercepted method

开发者 https://www.devze.com 2023-03-08 09:04 出处:网络
In method interception with AopAlliance is there a way to call a method from the class who\'s method was intercepted?

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

For example:

publi开发者_运维技巧c 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.


How about

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

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

0

精彩评论

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

关注公众号