Class AbstractContext

java.lang.Object
com.vaadin.quarkus.context.AbstractContext
All Implemented Interfaces:
io.quarkus.arc.InjectableContext, jakarta.enterprise.context.spi.AlterableContext, jakarta.enterprise.context.spi.Context
Direct Known Subclasses:
RouteScopedContext, UIScopedContext, VaadinServiceScopedContext, VaadinSessionScopedContext

public abstract class AbstractContext extends Object implements io.quarkus.arc.InjectableContext
A modified copy of org.apache.deltaspike.core.util.context.AbstractContext. A skeleton containing the most important parts of a custom CDI Context. An implementing Context needs to implement the missing methods from the AlterableContext interface and getContextualStorage(Contextual, boolean).
  • Nested Class Summary

    Nested classes/interfaces inherited from interface io.quarkus.arc.InjectableContext

    io.quarkus.arc.InjectableContext.ContextState
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Make sure that the Context is really active.
    void
     
    void
    destroy(jakarta.enterprise.context.spi.Contextual<?> bean)
    Destroy the Contextual Instance of the given Bean.
    void
    destroys all the Contextual Instances in the Storage returned by getContextualStorage(Contextual, boolean).
    Destroys all the Contextual Instances in the specified ContextualStorage.
    static void
    destroyBean(jakarta.enterprise.context.spi.Contextual bean, ContextualInstanceInfo<?> contextualInstanceInfo)
     
    <T> T
    get(jakarta.enterprise.context.spi.Contextual<T> bean)
     
    <T> T
    get(jakarta.enterprise.context.spi.Contextual<T> bean, jakarta.enterprise.context.spi.CreationalContext<T> creationalContext)
     
    Gets all active contextual storages.
    protected abstract ContextualStorage
    getContextualStorage(jakarta.enterprise.context.spi.Contextual<?> contextual, boolean createIfNotExist)
    An implementation has to return the underlying storage which contains the items held in the Context.
    io.quarkus.arc.InjectableContext.ContextState
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface jakarta.enterprise.context.spi.Context

    getScope, isActive

    Methods inherited from interface io.quarkus.arc.InjectableContext

    destroy, getIfActive, getStateIfActive, isNormal
  • Constructor Details

    • AbstractContext

      public AbstractContext()
  • Method Details

    • getContextualStorage

      protected abstract ContextualStorage getContextualStorage(jakarta.enterprise.context.spi.Contextual<?> contextual, boolean createIfNotExist)
      An implementation has to return the underlying storage which contains the items held in the Context.
      Parameters:
      contextual - the contextual type
      createIfNotExist - whether a ContextualStorage shall get created if it doesn't yet exist.
      Returns:
      the underlying storage
    • getActiveContextualStorages

      protected List<ContextualStorage> getActiveContextualStorages()
      Gets all active contextual storages.
      Returns:
      a list of contextual storages.
    • get

      public <T> T get(jakarta.enterprise.context.spi.Contextual<T> bean)
      Specified by:
      get in interface jakarta.enterprise.context.spi.Context
    • get

      public <T> T get(jakarta.enterprise.context.spi.Contextual<T> bean, jakarta.enterprise.context.spi.CreationalContext<T> creationalContext)
      Specified by:
      get in interface jakarta.enterprise.context.spi.Context
    • destroy

      public void destroy(jakarta.enterprise.context.spi.Contextual<?> bean)
      Destroy the Contextual Instance of the given Bean.
      Specified by:
      destroy in interface jakarta.enterprise.context.spi.AlterableContext
      Parameters:
      bean - dictates which bean shall get cleaned up
    • destroyAllActive

      public void destroyAllActive()
      destroys all the Contextual Instances in the Storage returned by getContextualStorage(Contextual, boolean).
    • destroyAllActive

      public static Map<Object,ContextualInstanceInfo<?>> destroyAllActive(ContextualStorage storage)
      Destroys all the Contextual Instances in the specified ContextualStorage. This is a static method to allow various holder objects to cleanup properly in @PreDestroy.
      Parameters:
      storage - a contextual storage
      Returns:
      a storage map of destroyed objects
    • destroy

      public void destroy()
      Specified by:
      destroy in interface io.quarkus.arc.InjectableContext
    • getState

      public io.quarkus.arc.InjectableContext.ContextState getState()
      Specified by:
      getState in interface io.quarkus.arc.InjectableContext
    • checkActive

      protected void checkActive()
      Make sure that the Context is really active.
      Throws:
      jakarta.enterprise.context.ContextNotActiveException - if there is no active Context for the current Thread.
    • destroyBean

      public static void destroyBean(jakarta.enterprise.context.spi.Contextual bean, ContextualInstanceInfo<?> contextualInstanceInfo)