Package com.google.inject.internal
Class InternalContext
java.lang.Object
com.google.inject.internal.InternalContext
- All Implemented Interfaces:
AutoCloseable
Internal context. Used to coordinate injections and support circular dependencies.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final IdentityHashMap<Object, ConstructionContext<?>> private Dependency<?> Keeps track of the type that is currently being requested for injection.private intThe number of timesenter()has been called + 1 for initial construction.private final InjectorImpl.InjectorOptionsprivate final Object[]A single element array to clear when theenterCounthits0. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Should be called any any method that received an instance via InjectorImpl.enterContext().(package private) voidenter()Should only be called by InjectorImpl.enterContext().(package private) <T> ConstructionContext<T> (package private) Dependency<?> (package private) InjectorImpl.InjectorOptions(package private) voidsetDependency(Dependency<?> dependency) Used to set the current dependency.
-
Field Details
-
options
-
constructionContexts
-
dependency
Keeps track of the type that is currently being requested for injection. -
enterCount
private int enterCountThe number of timesenter()has been called + 1 for initial construction. This value is decremented whenis called.invalid reference
#exit() -
toClear
A single element array to clear when theenterCounthits0.This is the value stored in the
InjectorImpl.localContextthread local.
-
-
Constructor Details
-
InternalContext
InternalContext(InjectorImpl.InjectorOptions options, Object[] toClear)
-
-
Method Details
-
enter
void enter()Should only be called by InjectorImpl.enterContext(). -
close
public void close()Should be called any any method that received an instance via InjectorImpl.enterContext().- Specified by:
closein interfaceAutoCloseable
-
getInjectorOptions
InjectorImpl.InjectorOptions getInjectorOptions() -
getConstructionContext
-
getDependency
Dependency<?> getDependency() -
setDependency
Used to set the current dependency.The currentDependency field is only used by InternalFactoryToProviderAdapter to propagate information to singleton scope. See comments in that class about alternatives.
-