Top Description Inners Fields Constructors Methods
com.google.inject.internal

pack-priv final Class InjectorShell

extends Object
Class Inheritance
Static Imports
com.google.common.base.Preconditions.checkState, com.google.inject.Scopes.SINGLETON, com.google.inject.internal.GuiceInternal.GUICE_INTERNAL

InjectorShell is used by InternalInjectorCreator to recursively create a tree of uninitialized Injectors. Each InjectorShell corresponds to either the top-level root injector, or a private child injector.

The root InjectorShell extracts elements from its list of modules and processes these elements to aggregate data that is used to populate its injector's fields. Child injectors are constructed similarly, but using PrivateElements instead of modules.

It is necessary to create the root and child injectors in a single batch because there can be bidirectional parent <-> child injector dependencies that require the entire tree of injectors to be initialized together in the InternalInjectorCreator.

Author
[email protected] (Jesse Wilson)

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
private static class
private static class
private static class
private static class

Field Summary

Modifier and TypeField and Description
private final List<Element>
private final InjectorImpl

Constructor Summary

AccessConstructor and Description
private
InjectorShell(List<Element> elements, InjectorImpl injector)

Method Summary

Modifier and TypeMethod and Description
private static void
bindInjector(InjectorImpl injector)

The Injector is a special case because we allow both parent and child injectors to both have a binding for that key.

private static void
bindLogger(InjectorImpl injector)

The Logger is a special case because it knows the injection point of the injected member.

private static void
bindStage(InjectorImpl injector, Stage stage)

pack-priv List<Element>
pack-priv InjectorImpl
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

elementsback to summary
private final List<Element> elements
injectorback to summary
private final InjectorImpl injector

Constructor Detail

InjectorShellback to summary
private InjectorShell(List<Element> elements, InjectorImpl injector)

Method Detail

bindInjectorback to summary
private static void bindInjector(InjectorImpl injector)

The Injector is a special case because we allow both parent and child injectors to both have a binding for that key.

bindLoggerback to summary
private static void bindLogger(InjectorImpl injector)

The Logger is a special case because it knows the injection point of the injected member. It's the only binding that does this.

bindStageback to summary
private static void bindStage(InjectorImpl injector, Stage stage)
getElementsback to summary
pack-priv List<Element> getElements()
getInjectorback to summary
pack-priv InjectorImpl getInjector()
com.google.inject.internal back to summary

pack-priv Class InjectorShell.Builder

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private InjectorBindingData
private final List<Element>
private InjectorJitBindingData
private final List<Module>
private InjectorImpl.InjectorOptions
private InjectorImpl
private PrivateElementsImpl
privateElements

null unless this exists in a private environment

private Stage

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv void
addModules(Iterable<? extends Module> modules)

pack-priv List<InjectorShell>
build(Initializer initializer, ProcessedBindingData processedBindingData, ContinuousStopwatch stopwatch, Errors errors)

Creates and returns the injector shells for the current modules.

pack-priv Stage
pack-priv Object
lock()

Synchronize on this before calling build.

pack-priv InjectorShell.Builder
pack-priv InjectorShell.Builder
pack-priv InjectorShell.Builder
stage(Stage stage)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bindingDataback to summary
private InjectorBindingData bindingData
elementsback to summary
private final List<Element> elements
jitBindingDataback to summary
private InjectorJitBindingData jitBindingData
modulesback to summary
private final List<Module> modules
optionsback to summary
private InjectorImpl.InjectorOptions options
parentback to summary
private InjectorImpl parent
privateElementsback to summary
private PrivateElementsImpl privateElements

null unless this exists in a private environment

stageback to summary
private Stage stage

Constructor Detail

Builderback to summary
pack-priv Builder()

Method Detail

addModulesback to summary
pack-priv void addModules(Iterable<? extends Module> modules)
buildback to summary
pack-priv List<InjectorShell> build(Initializer initializer, ProcessedBindingData processedBindingData, ContinuousStopwatch stopwatch, Errors errors)

Creates and returns the injector shells for the current modules. Multiple shells will be returned if any modules contain private environments. The primary injector will be first in the returned list.

getStageback to summary
pack-priv Stage getStage()
lockback to summary
pack-priv Object lock()

Synchronize on this before calling build.

parentback to summary
pack-priv InjectorShell.Builder parent(InjectorImpl parent)
privateElementsback to summary
pack-priv InjectorShell.Builder privateElements(PrivateElements privateElements)
stageback to summary
pack-priv InjectorShell.Builder stage(Stage stage)
com.google.inject.internal back to summary

private Class InjectorShell.InheritedScannersModule

extends Object
implements Module
Class Inheritance
  • java.lang.Object
  • com.google.inject.internal.InjectorShell.InheritedScannersModule
All Implemented Interfaces
com.google.inject.Module

Field Summary

Modifier and TypeField and Description
private final InjectorBindingData

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
configure(Binder binder)

Implements com.google.inject.Module.configure.

Contributes bindings and other configurations for this module to binder.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bindingDataback to summary
private final InjectorBindingData bindingData

Constructor Detail

InheritedScannersModuleback to summary
pack-priv InheritedScannersModule(InjectorBindingData bindingData)

Method Detail

configureback to summary
public void configure(Binder binder)

Implements com.google.inject.Module.configure.

Doc from com.google.inject.Module.configure.

Contributes bindings and other configurations for this module to binder.

Do not invoke this method directly to install submodules. Instead use Binder#install(Module), which ensures that provider methods are discovered.

Annotations
@Override
com.google.inject.internal back to summary

private Class InjectorShell.InjectorFactory

extends Object
implements InternalFactory<Injector>, Provider<Injector>
Class Inheritance
All Implemented Interfaces
com.google.inject.Provider, jakarta.inject.Provider, com.google.inject.internal.InternalFactory

Field Summary

Modifier and TypeField and Description
private final Injector

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Injector
get(InternalContext
of this injection
context
,
Dependency<?> dependency, boolean
true if getting as a result of a linked binding
linked
)

Implements com.google.inject.internal.InternalFactory.get.

Creates an object to be injected.
public Injector
get()

Implements com.google.inject.Provider.get.

Provides an instance of T.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

injectorback to summary
private final Injector injector

Constructor Detail

InjectorFactoryback to summary
private InjectorFactory(Injector injector)

Method Detail

getback to summary
public Injector get(InternalContext context, Dependency<?> dependency, boolean linked)

Implements com.google.inject.internal.InternalFactory.get.

Doc from com.google.inject.internal.InternalFactory.get.

Creates an object to be injected.

Parameters
context:InternalContext

of this injection

linked:boolean

true if getting as a result of a linked binding

Returns:Injector

instance that was created

Annotations
@Override
getback to summary
public Injector get()

Implements com.google.inject.Provider.get.

Doc from com.google.inject.Provider.get.

Provides an instance of T.

Returns:Injector

Doc from jakarta.inject.Provider.get.

instance of T.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
com.google.inject.internal back to summary

private Class InjectorShell.LoggerFactory

extends Object
implements InternalFactory<Logger>, Provider<Logger>
Class Inheritance
All Implemented Interfaces
com.google.inject.Provider, jakarta.inject.Provider, com.google.inject.internal.InternalFactory

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Logger
get(InternalContext
of this injection
context
,
Dependency<?> dependency, boolean
true if getting as a result of a linked binding
linked
)

Implements com.google.inject.internal.InternalFactory.get.

Creates an object to be injected.
public Logger
get()

Implements com.google.inject.Provider.get.

Provides an instance of T.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Constructor Detail

LoggerFactoryback to summary
private LoggerFactory()

Method Detail

getback to summary
public Logger get(InternalContext context, Dependency<?> dependency, boolean linked)

Implements com.google.inject.internal.InternalFactory.get.

Doc from com.google.inject.internal.InternalFactory.get.

Creates an object to be injected.

Parameters
context:InternalContext

of this injection

linked:boolean

true if getting as a result of a linked binding

Returns:Logger

instance that was created

Annotations
@Override
getback to summary
public Logger get()

Implements com.google.inject.Provider.get.

Doc from com.google.inject.Provider.get.

Provides an instance of T.

Returns:Logger

Doc from jakarta.inject.Provider.get.

instance of T.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
com.google.inject.internal back to summary

private Class InjectorShell.RootModule

extends Object
implements Module
Class Inheritance
All Implemented Interfaces
com.google.inject.Module

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
configure(Binder binder)

Implements com.google.inject.Module.configure.

Contributes bindings and other configurations for this module to binder.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

RootModuleback to summary
private RootModule()

Method Detail

configureback to summary
public void configure(Binder binder)

Implements com.google.inject.Module.configure.

Doc from com.google.inject.Module.configure.

Contributes bindings and other configurations for this module to binder.

Do not invoke this method directly to install submodules. Instead use Binder#install(Module), which ensures that provider methods are discovered.

Annotations
@Override