Package org.apache.webbeans.spi
Interface ContextsService
-
public interface ContextsService
Contexts services provides demarcation methods for each context that is defined in the specification. SPI providers implement related method that it supports.For example, web container supports request, session conversation, application, singleton and dependent contexts.
- Version:
- $Rev$ $Date$
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
destroy(Object destroyObject)
Destroys container contexts service.void
endContext(Class<? extends Annotation> scopeType, Object endParameters)
Ends the context with the given scope type.jakarta.enterprise.context.spi.Context
getCurrentContext(Class<? extends Annotation> scopeType)
Gets current context with given scope type with respect to the current thread of execution.jakarta.enterprise.context.spi.Context
getCurrentContext(Class<? extends Annotation> scopeType, boolean createIfNotExists)
Gets current context with given scope type with respect to the current thread of execution.void
init(Object initializeObject)
Initialize container contexts service.void
removeThreadLocals()
Whenever a thread ends we need to remove any ThreadLocals from the ContextsServicevoid
setSupportConversations(boolean supportConversations)
This method can be used to disable conversation support in core CDI.void
startContext(Class<? extends Annotation> scopeType, Object startParameter)
Starts the context with the given scope type.
-
-
-
Method Detail
-
init
void init(Object initializeObject)
Initialize container contexts service.- Parameters:
initializeObject
- any initialize object
-
destroy
void destroy(Object destroyObject)
Destroys container contexts service.- Parameters:
destroyObject
- any destroy parameter
-
getCurrentContext
jakarta.enterprise.context.spi.Context getCurrentContext(Class<? extends Annotation> scopeType)
Gets current context with given scope type with respect to the current thread of execution.If there is not current context, it returns null.
- Parameters:
scopeType
- context scope type- Returns:
- current context with given scope type
-
getCurrentContext
jakarta.enterprise.context.spi.Context getCurrentContext(Class<? extends Annotation> scopeType, boolean createIfNotExists)
Gets current context with given scope type with respect to the current thread of execution.If there is not current context, it will try to create one if
createIfNotExists
is set. This is mostly usefull for the SessionContext. If there is no HttpSession yet and thecreateIfNotExists
is set tofalse
then we do not create the HttpSession.- Parameters:
scopeType
- context scope typecreateIfNotExists
- whether to create a new context if the underlying storage is not yet initialized- Returns:
- current context with given scope type
-
startContext
void startContext(Class<? extends Annotation> scopeType, Object startParameter) throws jakarta.enterprise.context.ContextException
Starts the context with the given scope type. If given scope type is not supported, there is no action.- Parameters:
scopeType
- scope typestartParameter
- any parameter- Throws:
jakarta.enterprise.context.ContextException
- if any exception thrown by starting context, it is wrapped insideContextException
and thrown.
-
endContext
void endContext(Class<? extends Annotation> scopeType, Object endParameters)
Ends the context with the given scope type. If given scope type is not supported, there is no action. Any exception thrown by the operation is catched and logged by the container.- Parameters:
scopeType
- scope typeendParameters
- any end parameter
-
removeThreadLocals
void removeThreadLocals()
Whenever a thread ends we need to remove any ThreadLocals from the ContextsService
-
setSupportConversations
void setSupportConversations(boolean supportConversations)
This method can be used to disable conversation support in core CDI. This is needed as the spec defines that a user can define it's own Conversation handling by providing a Filter with the name "CDI Conversation Filter".- Parameters:
supportConversations
- whether converstaions should be supported
-
-