final class InternalContext
extends java.lang.Object
implements java.lang.AutoCloseable
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.Object,ConstructionContext<?>> |
constructionContexts |
private Dependency<?> |
dependency
Keeps track of the type that is currently being requested for injection.
|
private java.lang.Object[] |
dependencyStack
Keeps track of the hierarchy of types needed during injection.
|
private int |
dependencyStackSize |
private int |
enterCount
The number of times
enter() has been called + 1 for initial construction. |
private InjectorImpl.InjectorOptions |
options |
private java.lang.Object[] |
toClear
A single element array to clear when the
enterCount hits 0 . |
Constructor and Description |
---|
InternalContext(InjectorImpl.InjectorOptions options,
java.lang.Object[] toClear) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Should be called any any method that received an instance via InjectorImpl.enterContext().
|
private void |
doPushState(java.lang.Object dependencyOrKey,
java.lang.Object source) |
(package private) void |
enter()
Should only be called by InjectorImpl.enterContext().
|
(package private) <T> ConstructionContext<T> |
getConstructionContext(java.lang.Object key) |
(package private) Dependency<?> |
getDependency() |
(package private) java.util.List<DependencyAndSource> |
getDependencyChain()
Returns the current dependency chain (all the state stored in the dependencyStack).
|
(package private) InjectorImpl.InjectorOptions |
getInjectorOptions() |
(package private) void |
popState()
Pops from the state without setting a dependency.
|
(package private) void |
popStateAndSetDependency(Dependency<?> newDependency)
Pops the current state & sets the new dependency.
|
(package private) Dependency<?> |
pushDependency(Dependency<?> dependency,
java.lang.Object source)
Sets the new current dependency & adds it to the state.
|
(package private) void |
pushState(Key<?> key,
java.lang.Object source)
Adds to the state without setting the dependency.
|
private final InjectorImpl.InjectorOptions options
private final java.util.Map<java.lang.Object,ConstructionContext<?>> constructionContexts
private Dependency<?> dependency
private java.lang.Object[] dependencyStack
This is a pairwise combination of dependencies and sources, with dependencies or keys on even indices, and sources on odd indices. This structure is to avoid the memory overhead of DependencyAndSource objects, which can add to several tens of megabytes in large applications.
private int dependencyStackSize
private int enterCount
enter()
has been called + 1 for initial construction. This value
is decremented when #exit()
is called.private final java.lang.Object[] toClear
enterCount
hits 0
.
This is the value stored in the InjectorImpl.localContext
thread local.
InternalContext(InjectorImpl.InjectorOptions options, java.lang.Object[] toClear)
void enter()
public void close()
close
in interface java.lang.AutoCloseable
InjectorImpl.InjectorOptions getInjectorOptions()
<T> ConstructionContext<T> getConstructionContext(java.lang.Object key)
Dependency<?> getDependency()
Dependency<?> pushDependency(Dependency<?> dependency, java.lang.Object source)
void popStateAndSetDependency(Dependency<?> newDependency)
void pushState(Key<?> key, java.lang.Object source)
private void doPushState(java.lang.Object dependencyOrKey, java.lang.Object source)
void popState()
java.util.List<DependencyAndSource> getDependencyChain()