Interface InjectableContext

  • All Superinterfaces:
    javax.enterprise.context.spi.AlterableContext, javax.enterprise.context.spi.Context
    All Known Subinterfaces:
    ManagedContext

    public interface InjectableContext
    extends javax.enterprise.context.spi.AlterableContext
    A context implementing this interface makes it possible to capture and view its state via the InjectableContext.ContextState. It also allows users to destroy all contextual instances within this context.
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      void destroy()
      Destroy all existing contextual instances.
      default void destroy​(InjectableContext.ContextState state)
      Destroy all contextual instances from the given state.
      default <T> T getIfActive​(javax.enterprise.context.spi.Contextual<T> contextual, Function<javax.enterprise.context.spi.Contextual<T>,​javax.enterprise.context.spi.CreationalContext<T>> creationalContextFunction)
      If the context is active then return an existing instance of certain contextual type or create a new instance, otherwise return a null value.
      InjectableContext.ContextState getState()  
      default boolean isNormal()  
      • Methods inherited from interface javax.enterprise.context.spi.AlterableContext

        destroy
      • Methods inherited from interface javax.enterprise.context.spi.Context

        get, get, getScope, isActive
    • Method Detail

      • destroy

        void destroy()
        Destroy all existing contextual instances.
      • getIfActive

        default <T> T getIfActive​(javax.enterprise.context.spi.Contextual<T> contextual,
                                  Function<javax.enterprise.context.spi.Contextual<T>,​javax.enterprise.context.spi.CreationalContext<T>> creationalContextFunction)
        If the context is active then return an existing instance of certain contextual type or create a new instance, otherwise return a null value. This allows for the Context.isActive() check and the actual creation to happen in a single method, which gives a performance benefit by performing fewer thread local operations.
        Type Parameters:
        T - the type of contextual type
        Parameters:
        contextual - the contextual type
        creationalContextFunction - the creational context function
        Returns:
        the contextual instance, or a null value
      • destroy

        default void destroy​(InjectableContext.ContextState state)
        Destroy all contextual instances from the given state.

        The default implementation is not optimized and does not guarantee proper sychronization. Implementations of this interface are encouraged to provide an optimized implementation of this method.

        Parameters:
        state -
      • isNormal

        default boolean isNormal()
        Returns:
        true if this context represents a normal scope