Status: New
Owner: ----
New issue 390 by taowen: bindInterceptor in child injector
http://code.google.com/p/google-guice/issues/detail?id=390
@Test
public void test() {
TestObject testObject =
Guice.createInjector().createChildInjector(new AbstractModule() {
protected void configure() {
bindInterceptor(Matchers.any(), Matchers.any(), new
TestMethodInterceptor());
}
}).getInstance(TestObject.class);
testObject.hello();
}
public static class TestObject {
public void hello() {
System.out.println("Hello");
}
}
public static class TestMethodInterceptor implements MethodInterceptor {
public Object invoke(MethodInvocation invocation) throws Throwable {
throw new UnsupportedOperationException();
}
}
the test will println hello, instead of throw
UnsupportedOperationException. I guess the default binding is always fall
back to the parent injector, so the interceptor bind in the child injector
is not picked up. I am not sure this is a issue, or could be fixed. A work
around is to bind(TestObject.class) in the child injector.
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"google-guice-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-guice-dev?hl=en
-~----------~----~----~----~------~----~------~--~---