Class AbstractContext

java.lang.Object
org.jboss.weld.contexts.AbstractContext
All Implemented Interfaces:
jakarta.enterprise.context.spi.AlterableContext, jakarta.enterprise.context.spi.Context
Direct Known Subclasses:
AbstractManagedContext, AbstractSharedContext

public abstract class AbstractContext extends Object implements jakarta.enterprise.context.spi.AlterableContext
Base for the Context implementations. Delegates calls to the abstract getBeanStore and getActive to allow for different implementations (storage types and ThreadLocal vs. shared)
Author:
Nicklas Karlsson, Pete Muir
  • Constructor Summary

    Constructors
    Constructor
    Description
    AbstractContext(String contextId, boolean multithreaded)
    Constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Allows contexts that are initialized lazily to plug in additional logic.
    void
     
    protected void
    Destroys the context
    void
    destroy(jakarta.enterprise.context.spi.Contextual<?> contextual)
     
    <T> T
    get(jakarta.enterprise.context.spi.Contextual<T> contextual)
     
    <T> T
    get(jakarta.enterprise.context.spi.Contextual<T> contextual, jakarta.enterprise.context.spi.CreationalContext<T> creationalContext)
    Get the bean if it exists in the contexts.
    protected abstract BeanStore
    A method that returns the actual bean store implementation
    protected static <T> jakarta.enterprise.context.spi.Contextual<T>
    getContextual(String contextId, String id)
     
    protected org.jboss.weld.serialization.spi.BeanIdentifier
    getId(jakarta.enterprise.context.spi.Contextual<?> contextual)
     
    protected org.jboss.weld.bootstrap.api.ServiceRegistry
     
    protected boolean
     

    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
  • Constructor Details

    • AbstractContext

      public AbstractContext(String contextId, boolean multithreaded)
      Constructor
  • Method Details

    • get

      public <T> T get(jakarta.enterprise.context.spi.Contextual<T> contextual, jakarta.enterprise.context.spi.CreationalContext<T> creationalContext)
      Get the bean if it exists in the contexts.
      Specified by:
      get in interface jakarta.enterprise.context.spi.Context
      Returns:
      An instance of the bean
      Throws:
      jakarta.enterprise.context.ContextNotActiveException - if the context is not active
    • get

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

      public void destroy(jakarta.enterprise.context.spi.Contextual<?> contextual)
      Specified by:
      destroy in interface jakarta.enterprise.context.spi.AlterableContext
    • destroy

      protected void destroy()
      Destroys the context
    • getBeanStore

      protected abstract BeanStore getBeanStore()
      A method that returns the actual bean store implementation
      Returns:
      The bean store
    • cleanup

      public void cleanup()
    • getContextual

      protected static <T> jakarta.enterprise.context.spi.Contextual<T> getContextual(String contextId, String id)
    • getId

      protected org.jboss.weld.serialization.spi.BeanIdentifier getId(jakarta.enterprise.context.spi.Contextual<?> contextual)
    • getServiceRegistry

      protected org.jboss.weld.bootstrap.api.ServiceRegistry getServiceRegistry()
    • checkContextInitialized

      protected void checkContextInitialized()
      Allows contexts that are initialized lazily to plug in additional logic.
    • isMultithreaded

      protected boolean isMultithreaded()