Class ImmediateContext

java.lang.Object
org.glassfish.hk2.utilities.ImmediateContext
All Implemented Interfaces:
Context<Immediate>

@Singleton @Visibility(LOCAL) public class ImmediateContext extends Object implements Context<Immediate>
This is the Context implementation for the Immediate scope
  • Field Details

  • Constructor Details

    • ImmediateContext

      @Inject private ImmediateContext(ServiceLocator locator)
  • Method Details

    • getScope

      public Class<? extends Annotation> getScope()
      Description copied from interface: Context
      The scope for which this is the context
      Specified by:
      getScope in interface Context<Immediate>
      Returns:
      may not return null, must return the scope for which this is a context
    • findOrCreate

      public <U> U findOrCreate(ActiveDescriptor<U> activeDescriptor, ServiceHandle<?> root)
      Description copied from interface: Context
      Creates a contextual instance of this ActiveDescriptor by calling its create method if there is no other matching contextual instance. If there is already a contextual instance it is returned. If parent is null then this must work like the find call
      Specified by:
      findOrCreate in interface Context<Immediate>
      Parameters:
      activeDescriptor - The descriptor to create
      root - The root handle
      Returns:
      The service
    • containsKey

      public boolean containsKey(ActiveDescriptor<?> descriptor)
      Description copied from interface: Context
      Determines if this context has a value for the given key
      Specified by:
      containsKey in interface Context<Immediate>
      Parameters:
      descriptor - The descriptor to find
      Returns:
      true if this service has been created
    • destroyOne

      public void destroyOne(ActiveDescriptor<?> descriptor)
      Description copied from interface: Context
      This method is called when ServiceHandle.destroy() method is called. It is up to the context implementation whether or not to honor this destruction request based on the lifecycle requirements of the context
      Specified by:
      destroyOne in interface Context<Immediate>
      Parameters:
      descriptor - A non-null descriptor upon which ServiceHandle.destroy() has been called
    • destroyOne

      private void destroyOne(ActiveDescriptor<?> descriptor, List<ImmediateErrorHandler> errorHandlers)
      Destroys a single descriptor
      Parameters:
      descriptor - The descriptor to destroy
      errorHandlers - The handlers for exceptions (if null will get from service locator)
    • supportsNullCreation

      public boolean supportsNullCreation()
      Description copied from interface: Context
      Returns true if the findOrCreate method can return null
      Specified by:
      supportsNullCreation in interface Context<Immediate>
      Returns:
      true if null is a legal value from the findOrCreate method
    • isActive

      public boolean isActive()
      Description copied from interface: Context
      True if this context is active, false otherwise
      Specified by:
      isActive in interface Context<Immediate>
      Returns:
      true if this context is active, false otherwise
    • shutdown

      public void shutdown()
      For when the server shuts down
      Specified by:
      shutdown in interface Context<Immediate>
    • getImmediateServices

      private List<ActiveDescriptor<?>> getImmediateServices()
    • getValidationFilter

      public Filter getValidationFilter()
    • doWork

      public void doWork()