You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using a couple of different injectors and I want to ensure I don't accidentally access a class that's bound automatically from an injector, especially since its scope is important.
For instance if I have a method Foo that is "illegally" requesting a Bar:
class Bar { @Inject Bar() {} } // Shouldn't be accessible in Foo's injector
class Foo { @Inject Foo(Bar bar) {} } // Binding should fail here
Apparently, the only way to do this presently is to force a run-time error with a provider method.
I'd like Guice support to force an automatic binding to fail only on a specific class. I think it could work via requireExplicitBindings() with variable length parameter list of classes to prohibit.
From glenviewjeff on July 19, 2012 16:32:35
I'm using a couple of different injectors and I want to ensure I don't accidentally access a class that's bound automatically from an injector, especially since its scope is important.
For instance if I have a method Foo that is "illegally" requesting a Bar:
class Bar {
@
Inject Bar() {} } // Shouldn't be accessible in Foo's injectorclass Foo {
@
Inject Foo(Bar bar) {} } // Binding should fail hereApparently, the only way to do this presently is to force a run-time error with a provider method.
I'd like Guice support to force an automatic binding to fail only on a specific class. I think it could work via requireExplicitBindings() with variable length parameter list of classes to prohibit.
Original issue: http://code.google.com/p/google-guice/issues/detail?id=716
The text was updated successfully, but these errors were encountered: