Binder.newPrivateBinder() private environment. The primary injector is not necessarily a
top-level injector.
Injector construction happens in two phases.
the tool stage
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class | InternalInjectorCreator.
|
| Modifier and Type | Field and Description |
|---|---|
| private final Errors | |
| private final Initializer | |
| private final InjectionRequestProcessor | |
| private final ProcessedBindingData | |
| private final InjectorShell. | |
| private List | |
| private final ContinuousStopwatch |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public InternalInjectorCreator | |
| public Injector | |
| private void | |
| private void | |
| private boolean | |
| pack-priv void | loadEagerSingletons(InjectorImpl injector, Stage stage, final Errors errors)
Loads eager singletons, or all singletons if we're in Stage.PRODUCTION. |
| public InternalInjectorCreator | |
| private Injector | |
| public InternalInjectorCreator |
| errors | back to summary |
|---|---|
| private final Errors errors | |
| initializer | back to summary |
|---|---|
| private final Initializer initializer | |
| injectionRequestProcessor | back to summary |
|---|---|
| private final InjectionRequestProcessor injectionRequestProcessor | |
| processedBindingData | back to summary |
|---|---|
| private final ProcessedBindingData processedBindingData | |
| shellBuilder | back to summary |
|---|---|
| private final InjectorShell. | |
| shells | back to summary |
|---|---|
| private List<InjectorShell> shells | |
| stopwatch | back to summary |
|---|---|
| private final ContinuousStopwatch stopwatch | |
| InternalInjectorCreator | back to summary |
|---|---|
| public InternalInjectorCreator() | |
| addModules | back to summary |
|---|---|
| public InternalInjectorCreator addModules(Iterable<? extends Module> modules) | |
| build | back to summary |
|---|---|
| public Injector build() | |
| initializeStatically | back to summary |
|---|---|
| private void initializeStatically() Initialize and validate everything. | |
| injectDynamically | back to summary |
|---|---|
| private void injectDynamically() Inject everything that can be injected. This method is intentionally not synchronized. If we locked while injecting members (ie. running user code), things would deadlock should the user code build a just-in-time binding from another thread. | |
| isEagerSingleton | back to summary |
|---|---|
| private boolean isEagerSingleton(InjectorImpl injector, BindingImpl<?> binding, Stage stage) | |
| loadEagerSingletons | back to summary |
|---|---|
| pack-priv void loadEagerSingletons(InjectorImpl injector, Stage stage, final Errors errors) Loads eager singletons, or all singletons if we're in Stage.PRODUCTION. Bindings discovered while we're binding these singletons are not be eager. | |
| parentInjector | back to summary |
|---|---|
| public InternalInjectorCreator parentInjector(InjectorImpl parent) Sets the parent of the injector to-be-constructed. As a side effect, this sets this injector's
stage to the stage of | |
| primaryInjector | back to summary |
|---|---|
| private Injector primaryInjector() Returns the injector being constructed. This is not necessarily the root injector. | |
| stage | back to summary |
|---|---|
| public InternalInjectorCreator stage(Stage stage) | |
Injector exposed to users in Stage#TOOL.
| Modifier and Type | Field and Description |
|---|---|
| private final Injector |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public Injector | createChildInjector(Iterable<? extends Module> modules)
Implements com. |
| public Injector | createChildInjector(Module... modules)
Implements com. |
| public <T> List | findBindingsByType(TypeLiteral<T> type)
Implements com. type.
|
| public Map | getAllBindings()
Implements com. |
| public Map | getAllMembersInjectorInjectionPoints()
Implements com. getMembersInjector (either directly
or indirectly, e.g. through injectMembers.
|
| public <T> Binding | getBinding(Key<T> key)
Implements com. |
| public <T> Binding | getBinding(Class<T> type)
Implements com. |
| public Map | getBindings()
Implements com. |
| public List | getElements()
Implements com. |
| public <T> Binding | getExistingBinding(Key<T> key)
Implements com. |
| public <T> T | getInstance(Key<T> key)
Implements com. getProvider(key).get().
|
| public <T> T | getInstance(Class<T> type)
Implements com. getProvider(type).get().
|
| public <T> MembersInjector | getMembersInjector(TypeLiteral<T>
type to get members injector for typeLiteral)Implements com. T.
|
| public <T> MembersInjector | getMembersInjector(Class<T>
type to get members injector for type)Implements com. T.
|
| public Injector | getParent()
Implements com. null if this is a top-level injector.
|
| public <T> Provider | getProvider(Key<T> key)
Implements com. |
| public <T> Provider | getProvider(Class<T> type)
Implements com. |
| public Map | getScopeBindings()
Implements com. |
| public Set | getTypeConverterBindings()
Implements com. |
| public void | injectMembers(Object
to inject members on o)Implements com. instance.
|
| delegateInjector | back to summary |
|---|---|
| private final Injector delegateInjector | |
| ToolStageInjector | back to summary |
|---|---|
| pack-priv ToolStageInjector(Injector delegateInjector) | |
| createChildInjector | back to summary |
|---|---|
| public Injector createChildInjector(Iterable<? extends Module> modules) Implements com. Doc from com. Returns a new injector that inherits all state from this injector. All bindings, scopes, interceptors and type converters are inherited -- they are visible to the child injector. Elements of the child injector are not visible to its parent. Just-in-time bindings created for child injectors will be created in an ancestor injector whenever possible. This allows for scoped instances to be shared between injectors. Use explicit bindings to prevent bindings from being shared with the parent injector. Optional injections in just-in-time bindings (created in the parent injector) may be silently ignored if the optional dependencies are from the child injector. No key may be bound by both an injector and one of its ancestors. This includes just-in-time
bindings. The lone exception is the key for When using hierarchical injectors (via
| |
| createChildInjector | back to summary |
|---|---|
| public Injector createChildInjector(Module... modules) Implements com. Doc from com. Returns a new injector that inherits all state from this injector. All bindings, scopes, interceptors and type converters are inherited -- they are visible to the child injector. Elements of the child injector are not visible to its parent. Just-in-time bindings created for child injectors will be created in an ancestor injector whenever possible. This allows for scoped instances to be shared between injectors. Use explicit bindings to prevent bindings from being shared with the parent injector. No key may be bound by both an injector and one of its ancestors. This includes just-in-time
bindings. The lone exception is the key for
| |
| findBindingsByType | back to summary |
|---|---|
| public <T> List Implements com. Doc from com. Returns all explicit bindings for This method is part of the Guice SPI and is intended for use by tools and extensions.
| |
| getAllBindings | back to summary |
|---|---|
| public Map Implements com. Doc from com. Returns a snapshot of this injector's bindings, both explicit and
just-in-time. The returned map is immutable; it contains only the bindings that were
present when The returned map does not include bindings inherited from a This method is part of the Guice SPI and is intended for use by tools and extensions.
| |
| getAllMembersInjectorInjectionPoints | back to summary |
|---|---|
| public Map Implements com. Doc from com. Returns the injection points created for calls to This excludes any injection points from elements (which are accessible from each element via
the SPI), unless The returned multimap does not include data inherited from a This method is part of the Guice SPI and is intended for use by tools and extensions.
| |
| getBinding | back to summary |
|---|---|
| public <T> Binding Implements com. Doc from com. Returns the binding for the given injection key. This will be an explicit bindings if the key was bound explicitly by a module, or an implicit binding otherwise. The implicit binding will be created if necessary. This method is part of the Guice SPI and is intended for use by tools and extensions.
| |
| getBinding | back to summary |
|---|---|
| public <T> Binding Implements com. Doc from com. Returns the binding for the given type. This will be an explicit bindings if the injection key was bound explicitly by a module, or an implicit binding otherwise. The implicit binding will be created if necessary. This method is part of the Guice SPI and is intended for use by tools and extensions.
| |
| getBindings | back to summary |
|---|---|
| public Map Implements com. Doc from com. Returns this injector's explicit bindings. The returned map does not include bindings inherited from a This method is part of the Guice SPI and is intended for use by tools and extensions.
| |
| getElements | back to summary |
|---|---|
| public List Implements com. Doc from com. Returns the elements that make up this injector. Note that not all kinds of elements are returned. The returned list does not include elements inherited from a The returned list is immutable; it contains only the elements that were present when The returned list does not include data inherited from a This method is part of the Guice SPI and is intended for use by tools and extensions.
| |
| getExistingBinding | back to summary |
|---|---|
| public <T> Binding Implements com. Doc from com. Returns the binding if it already exists, or null if does not exist. Unlike This method is part of the Guice SPI and is intended for use by tools and extensions.
| |
| getInstance | back to summary |
|---|---|
| public <T> T getInstance(Key<T> key) Implements com. Doc from com. Returns the appropriate instance for the given injection key; equivalent to
| |
| getInstance | back to summary |
|---|---|
| public <T> T getInstance(Class<T> type) Implements com. Doc from com. Returns the appropriate instance for the given injection type; equivalent to
| |
| getMembersInjector | back to summary |
|---|---|
| public <T> MembersInjector Implements com. Doc from com. Returns the members injector used to inject dependencies into methods and fields on instances
of the given type
| |
| getMembersInjector | back to summary |
|---|---|
| public <T> MembersInjector Implements com. Doc from com. Returns the members injector used to inject dependencies into methods and fields on instances
of the given type | |
| getParent | back to summary |
|---|---|
| public Injector getParent() Implements com. Doc from com. Returns this injector's parent, or
| |
| getProvider | back to summary |
|---|---|
| public <T> Provider Implements com. Doc from com. Returns the provider used to obtain instances for the given injection key. When feasible, avoid using this method, in favor of having Guice inject your dependencies ahead of time.
| |
| getProvider | back to summary |
|---|---|
| public <T> Provider Implements com. Doc from com. Returns the provider used to obtain instances for the given type. When feasible, avoid using this method, in favor of having Guice inject your dependencies ahead of time.
| |
| getScopeBindings | back to summary |
|---|---|
| public Map Implements com. Doc from com. Returns a map containing all scopes in the injector. The maps keys are scoping annotations like
This method is part of the Guice SPI and is intended for use by tools and extensions.
| |
| getTypeConverterBindings | back to summary |
|---|---|
| public Set Implements com. Doc from com. Returns a set containing all type converter bindings in the injector. The returned set is immutable. This method is part of the Guice SPI and is intended for use by tools and extensions.
| |
| injectMembers | back to summary |
|---|---|
| public void injectMembers(Object o) Implements com. Doc from com. Injects dependencies into the fields and methods of Whenever Guice creates an instance, it performs this injection automatically (after first performing constructor injection), so if you're able to let Guice create all your objects for you, you'll never need to use this method. | |