java.lang.Object | |
↳ | com.google.inject.InjectorBuilder |
The advanced entry point to the Guice framework. Creates Injector
s from
Module
s, allowing many options to be configured for the Injector.
Guice supports a model of development that draws clear boundaries between
APIs, Implementations of these APIs, Modules which configure these
implementations, and finally Applications which consist of a collection of
Modules. It is the Application, which typically defines your main()
method, that bootstraps the Guice Injector using the Guice
class, as
in this example:
public class FooApplication { public static void main(String[] args) { Injector injector = new InjectorBuilder(). .stage(Stage.PRODUCTION) . . . .addModules( new ModuleA(), new ModuleB(), . . . new FooApplicationFlagsModule(args) ) .build(); ); // Now just bootstrap the application and you're done FooStarter starter = injector.getInstance(FooStarter.class); starter.runApplication(); } }
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Adds more modules that will be used when the Injector is created.
| |||||||||||
Adds more modules that will be used when the Injector is created.
| |||||||||||
Builds the injector.
| |||||||||||
Prevents Guice from constructing a Proxy when a circular dependency
is found.
| |||||||||||
If explicit bindings are required, then classes that are not explicitly
bound in a module cannot be injected.
| |||||||||||
Sets the stage for the injector.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Adds more modules that will be used when the Injector is created.
Adds more modules that will be used when the Injector is created.
Prevents Guice from constructing a Proxy when a circular dependency is found.
If explicit bindings are required, then classes that are not explicitly
bound in a module cannot be injected. Bindings created through a linked
binding (bind(Foo.class).to(FooImpl.class)
) are allowed, but
the implicit binding (FooImpl) cannot be directly injected unless it is
also explicitly bound.
Tools can still retrieve bindings for implicit bindings (bindings created
through a linked binding) if explicit bindings are required, however
getProvider()
cannot be used.
By default, explicit bindings are not required.
Sets the stage for the injector. If the stage is PRODUCTION
,
singletons will be eagerly loaded when the Injector is built.