在Guice中,是否有一种方法可以在执行被拦截的方法(而不是在此之前)之后调用我的MethodInterceptor::invoke实现?
我已将当前代码添加到我的AbstractModule中
bindInterceptor(Matchers.subclassesOf(InterceptedClass.class), Matchers.annotatedWith(MyMethodAnnotation.class), new MyMethodInterceptor());发布于 2015-10-18 17:14:03
若要在拦截器中的方法调用后执行代码(这不仅适用于Guice),您必须使用try/finally组合:
public Object invoke(MethodInvocation invocation) throws Throwable {
try {
// code run before execution
return invocation.proceed();
} finally {
// code run after execution
}
}https://stackoverflow.com/questions/33195223
复制相似问题