Package com.google.inject.internal
Class InternalContext
- java.lang.Object
-
- com.google.inject.internal.InternalContext
-
- All Implemented Interfaces:
java.lang.AutoCloseable
final class InternalContext extends java.lang.Object implements java.lang.AutoCloseableInternal context. Used to coordinate injections and support circular dependencies.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.IdentityHashMap<java.lang.Object,ConstructionContext<?>>constructionContextsprivate Dependency<?>dependencyKeeps track of the type that is currently being requested for injection.private intenterCountThe number of timesenter()has been called + 1 for initial construction.private InjectorImpl.InjectorOptionsoptionsprivate java.lang.Object[]toClearA single element array to clear when theenterCounthits0.
-
Constructor Summary
Constructors Constructor Description InternalContext(InjectorImpl.InjectorOptions options, java.lang.Object[] toClear)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()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>getConstructionContext(java.lang.Object key)(package private) Dependency<?>getDependency()(package private) InjectorImpl.InjectorOptionsgetInjectorOptions()(package private) voidsetDependency(Dependency<?> dependency)Used to set the current dependency.
-
-
-
Field Detail
-
options
private final InjectorImpl.InjectorOptions options
-
constructionContexts
private final java.util.IdentityHashMap<java.lang.Object,ConstructionContext<?>> constructionContexts
-
dependency
private Dependency<?> dependency
Keeps track of the type that is currently being requested for injection.
-
enterCount
private int enterCount
The number of timesenter()has been called + 1 for initial construction. This value is decremented when#exit()is called.
-
toClear
private final java.lang.Object[] toClear
A single element array to clear when theenterCounthits0.This is the value stored in the
InjectorImpl.localContextthread local.
-
-
Constructor Detail
-
InternalContext
InternalContext(InjectorImpl.InjectorOptions options, java.lang.Object[] toClear)
-
-
Method Detail
-
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 interfacejava.lang.AutoCloseable
-
getInjectorOptions
InjectorImpl.InjectorOptions getInjectorOptions()
-
getConstructionContext
<T> ConstructionContext<T> getConstructionContext(java.lang.Object key)
-
getDependency
Dependency<?> getDependency()
-
setDependency
void setDependency(Dependency<?> dependency)
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.
-
-