pombreda / google-guice

Automatically exported from code.google.com/p/google-guice
Apache License 2.0
0 stars 1 forks source link

requireExplicitBindings() method should support requiring explicit binding on individual classes #716

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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.

Original issue reported on code.google.com by glenview...@gmail.com on 19 Jul 2012 at 8:32