fixes issue 342 - ability to disable JIT bindings (require explicit bindings). this revision creates a new public facing API of:
.addModules(Iterable<? extends Module>)
There are three kinds of bindings Guice can handle: explicit, implicit, and JIT. Explicit bindings are where there's a bind() call for that type. Implicit bindings are where there's a bind(A).to(B) call (B is the implicit binding). JIT bindings are where there's no binding, but the code requests an injection.
The internals are changed so that if requireExplicitBindings() is called in the InjectorBuilder, then Guice will fail to create an Injector for any injection that is not an explicit binding. Implicit bindings are allowed to be used in a Module, but unless the implicit binding was also explicitly bound then no class can directly inject the implicit binding. Injector.get[Instance|Provider] will also fail for JIT or implicit bindings. Injector.getBinding will succeed if for explicit & implicit bindings (but it won't create new JIT bindings), but Binding.getProvider will fail for implicit bindings.
In a nutshell, if you requireExplicitBindings() is called, then the Module must explicitly bind everything that's injected. (@ProvidedBy & @ImplementedBy on types are still supported as shortcuts for implicit bindings.)
git-svn-id: https://google-guice.googlecode.com/svn/trunk@1141 d779f126-a31b-0410-b53b-1d3aecad763e
23 files changed