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

pack-priv final Class InternalContext

extends Object
implements AutoCloseable
Class Inheritance
All Implemented Interfaces
java.lang.AutoCloseable
Imports
com.google.inject.internal.InjectorImpl.InjectorOptions, com.google.inject.spi.Dependency, java.util.IdentityHashMap

Internal context. Used to coordinate injections and support circular dependencies.
Author
[email protected] (Bob Lee)

Field Summary

Modifier and TypeField and Description
private final IdentityHashMap<Object, ConstructionContext<?>>
private Dependency<?>
dependency

Keeps track of the type that is currently being requested for injection.

private int
enterCount

The number of times enter() has been called + 1 for initial construction.

private final InjectorImpl.InjectorOptions
private final Object[]
toClear

A single element array to clear when the enterCount hits 0.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements java.lang.AutoCloseable.close.

Should be called any any method that received an instance via InjectorImpl.enterContext().
pack-priv void
enter()

Should only be called by InjectorImpl.enterContext().

pack-priv <T> ConstructionContext<T>
pack-priv Dependency<?>
pack-priv InjectorImpl.InjectorOptions
pack-priv void
setDependency(Dependency<?> dependency)

Used to set the current dependency.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

constructionContextsback to summary
private final IdentityHashMap<Object, ConstructionContext<?>> constructionContexts
dependencyback to summary
private Dependency<?> dependency

Keeps track of the type that is currently being requested for injection.

enterCountback to summary
private int enterCount

The number of times enter() has been called + 1 for initial construction. This value is decremented when exit() is called.

optionsback to summary
private final InjectorImpl.InjectorOptions options
toClearback to summary
private final Object[] toClear

A single element array to clear when the enterCount hits 0.

This is the value stored in the InjectorImpl.localContext thread local.

Constructor Detail

InternalContextback to summary
pack-priv InternalContext(InjectorImpl.InjectorOptions options, Object[] toClear)

Method Detail

closeback to summary
public void close()

Implements java.lang.AutoCloseable.close.

Should be called any any method that received an instance via InjectorImpl.enterContext().

Annotations
@Override
enterback to summary
pack-priv void enter()

Should only be called by InjectorImpl.enterContext().

getConstructionContextback to summary
pack-priv <T> ConstructionContext<T> getConstructionContext(Object key)
Annotations
@SuppressWarnings:unchecked
getDependencyback to summary
pack-priv Dependency<?> getDependency()
getInjectorOptionsback to summary
pack-priv InjectorImpl.InjectorOptions getInjectorOptions()
setDependencyback to summary
pack-priv 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.