Class InternalContext

java.lang.Object
com.google.inject.internal.InternalContext
All Implemented Interfaces:
AutoCloseable

final class InternalContext extends Object implements AutoCloseable
Internal context. Used to coordinate injections and support circular dependencies.
  • Field Details

    • options

      private final InjectorImpl.InjectorOptions options
    • constructionContexts

      private final IdentityHashMap<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 times enter() has been called + 1 for initial construction. This value is decremented when #exit() is called.
    • toClear

      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 Details

  • 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:
      close in interface AutoCloseable
    • getInjectorOptions

      InjectorImpl.InjectorOptions getInjectorOptions()
    • getConstructionContext

      <T> ConstructionContext<T> getConstructionContext(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.