public void testGetThis() {
final AtomicReference<Object> lastTarget = new AtomicReference<>();
Injector injector =
Guice.createInjector(
new AbstractModule() {
@Override
protected void configure() {
bindInterceptor(
Matchers.any(),
Matchers.any(),
new MethodInterceptor() {
@Override
public Object invoke(MethodInvocation methodInvocation) throws Throwable {
lastTarget.set(methodInvocation.getThis());
return methodInvocation.proceed();
}
});
}
});
Interceptable interceptable = injector.getInstance(Interceptable.class);
interceptable.foo();
assertSame(interceptable, lastTarget.get());
}
MethodInterceptionTest.java 文件源码
java
阅读 19
收藏 0
点赞 0
评论 0
项目:guice
作者:
评论列表
文章目录