google / google/guice

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

Open
#716 0 comments 1 reaction 0 assignees View on GitHub
imported
Dominant language
Java
Stars
12.7k
Forks
1.7k
Avg merge
11m
Merged PRs (30d)
2

Description

_From [glenviewjeff](https://code.google.com/u/110087215095127878251/) 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 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: http://code.google.com/p/google-guice/issues/detail?id=716_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.