Package org.jboss.weld.contexts
Class AbstractContext
- java.lang.Object
-
- org.jboss.weld.contexts.AbstractContext
-
- All Implemented Interfaces:
AlterableContext,Context
- Direct Known Subclasses:
AbstractManagedContext,AbstractSharedContext
public abstract class AbstractContext extends Object implements 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
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidcheckContextInitialized()Allows contexts that are initialized lazily to plug in additional logic.voidcleanup()protected voiddestroy()Destroys the contextvoiddestroy(Contextual<?> contextual)Destroy the existing contextual instance.<T> Tget(Contextual<T> contextual)Return an existing instance of a certain contextual type or a null value.<T> Tget(Contextual<T> contextual, CreationalContext<T> creationalContext)Get the bean if it exists in the contexts.protected abstract BeanStoregetBeanStore()A method that returns the actual bean store implementationprotected static <T> Contextual<T>getContextual(String contextId, String id)protected org.jboss.weld.serialization.spi.BeanIdentifiergetId(Contextual<?> contextual)protected org.jboss.weld.bootstrap.api.ServiceRegistrygetServiceRegistry()protected booleanisMultithreaded()
-
-
-
Constructor Detail
-
AbstractContext
public AbstractContext(String contextId, boolean multithreaded)
Constructor
-
-
Method Detail
-
get
public <T> T get(Contextual<T> contextual, CreationalContext<T> creationalContext)
Get the bean if it exists in the contexts.- Specified by:
getin interfaceContext- Type Parameters:
T- the type of contextual type- Parameters:
contextual- the contextual typecreationalContext- the context in which the new instance will be created- Returns:
- An instance of the bean
- Throws:
ContextNotActiveException- if the context is not active- See Also:
javax.enterprise.context.spi.Context#get(BaseBean, boolean)
-
get
public <T> T get(Contextual<T> contextual)
Description copied from interface:ContextReturn an existing instance of a certain contextual type or a null value.
-
destroy
public void destroy(Contextual<?> contextual)
Description copied from interface:AlterableContextDestroy the existing contextual instance. If there is no existing instance, no action is taken.
- Specified by:
destroyin interfaceAlterableContext- Parameters:
contextual- the contextual type
-
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> Contextual<T> getContextual(String contextId, String id)
-
getId
protected org.jboss.weld.serialization.spi.BeanIdentifier getId(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()
-
-