Package org.jboss.weld.contexts
Class AbstractConversationContext<R,S>
java.lang.Object
org.jboss.weld.contexts.AbstractContext
org.jboss.weld.contexts.AbstractManagedContext
org.jboss.weld.contexts.AbstractBoundContext<R>
org.jboss.weld.contexts.AbstractConversationContext<R,S>
- All Implemented Interfaces:
jakarta.enterprise.context.spi.AlterableContext,jakarta.enterprise.context.spi.Context,BoundContext<R>,ConversationContext,ManagedContext,WeldAlterableContext
- Direct Known Subclasses:
BoundConversationContextImpl
public abstract class AbstractConversationContext<R,S>
extends AbstractBoundContext<R>
implements ConversationContext
The base of the conversation context, which can use a variety of storage
forms
- Author:
- Pete Muir, Jozef Hartinger, George Sapountzis, Marko Luksa
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAbstractConversationContext(String contextId, org.jboss.weld.bootstrap.api.ServiceRegistry services) -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate()Activate the Context.voidActivate the conversation context, using the id provided to attempt to restore a long-running conversationbooleanAssociate the context with the storage (for this thread).protected voidassociateRequest(ManagedConversation conversation) protected voidvoidconversationPromotedToLongRunning(ConversationImpl conversation) protected voidprotected abstract BoundBeanStorecreateRequestBeanStore(NamingScheme namingScheme, R request) protected abstract BoundBeanStorecreateSessionBeanStore(NamingScheme namingScheme, S session) voidDeactivate the Context, destroying any instances if the context is invalid.booleanprotected voiddestroyConversation(S session, String id, boolean fireEvents) booleandissociate(R request) Dissociate the context from the storage (for this thread).Generate a new, unique, conversation idlongGet the current concurrent access timeoutGet the conversation with the given id.protected ConversationIdGeneratorGet conversations currently known to the context.Get a handle the current conversation (transient or otherwise).longGet the default inactivity timeout.protected abstract StringGet the name of the parameter used to propagate the conversation idprotected RGet the associated storeprotected abstract ObjectgetRequestAttribute(R request, String name) Retrieve an attribute value from the requestClass<? extends Annotation>getScope()protected abstract ObjectgetSessionAttribute(R request, String name, boolean create) Get an attribute value from the session.protected abstract ObjectgetSessionAttributeFromSession(S session, String name) Get an attribute value from the session.getSessionAttributeNames(S session) protected abstract SgetSessionFromRequest(R request, boolean create) protected voidinitialize(String cid) voidMark the context as due for destruction when deactivate is called.protected booleanCheck if the context is currently associatedprotected abstract voidremoveRequestAttribute(R request, String name) Remove an attribute from the request.voidvoidsetConcurrentAccessTimeout(long timeout) Set the concurrent access timeoutvoidsetDefaultTimeout(long timeout) Set the default inactivity timeout.voidsetParameterName(String cid) Set the name of the parameter used to propagate the conversation idprotected abstract voidsetRequestAttribute(R request, String name, Object value) Set an attribute in the request.protected abstract voidsetSessionAttribute(R request, String name, Object value, boolean create) Set an attribute in the session.Methods inherited from class org.jboss.weld.contexts.AbstractBoundContext
cleanup, clearAndSet, getAllContextualInstances, getBeanStore, setBeanStoreMethods inherited from class org.jboss.weld.contexts.AbstractManagedContext
isActive, isValid, removeState, setActiveMethods inherited from class org.jboss.weld.contexts.AbstractContext
checkContextInitialized, destroy, destroy, get, get, getContextual, getId, getServiceRegistry, isMultithreadedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jakarta.enterprise.context.spi.AlterableContext
destroyMethods inherited from interface jakarta.enterprise.context.spi.Context
get, get, isActiveMethods inherited from interface org.jboss.weld.context.WeldAlterableContext
clearAndSet, getAllContextualInstances
-
Field Details
-
CONVERSATIONS_ATTRIBUTE_NAME
-
DESTRUCTION_QUEUE_ATTRIBUTE_NAME
-
-
Constructor Details
-
AbstractConversationContext
public AbstractConversationContext(String contextId, org.jboss.weld.bootstrap.api.ServiceRegistry services)
-
-
Method Details
-
getParameterName
Description copied from interface:ConversationContextGet the name of the parameter used to propagate the conversation id- Specified by:
getParameterNamein interfaceConversationContext- Returns:
- the name of the conversation id parameter
-
setParameterName
Description copied from interface:ConversationContextSet the name of the parameter used to propagate the conversation id- Specified by:
setParameterNamein interfaceConversationContext- Parameters:
cid- the name of the conversation id parameter
-
setConcurrentAccessTimeout
public void setConcurrentAccessTimeout(long timeout) Description copied from interface:ConversationContextSet the concurrent access timeout- Specified by:
setConcurrentAccessTimeoutin interfaceConversationContext- Parameters:
timeout- the timeout (in ms) for the concurrent access lock
-
getConcurrentAccessTimeout
public long getConcurrentAccessTimeout()Description copied from interface:ConversationContextGet the current concurrent access timeout- Specified by:
getConcurrentAccessTimeoutin interfaceConversationContext- Returns:
- the timeout (in ms) for the concurrent access lock
-
setDefaultTimeout
public void setDefaultTimeout(long timeout) Description copied from interface:ConversationContextSet the default inactivity timeout. This may be overridden on a per conversation basis usingConversation.setTimeout(long)- Specified by:
setDefaultTimeoutin interfaceConversationContext- Parameters:
timeout- the default inactivity timeout (in ms)
-
getDefaultTimeout
public long getDefaultTimeout()Description copied from interface:ConversationContextGet the default inactivity timeout. This may have been overridden on a per conversation basis.- Specified by:
getDefaultTimeoutin interfaceConversationContext- Returns:
- the default inactivity timeout (in ms)
-
associate
Description copied from interface:BoundContextAssociate the context with the storage (for this thread). OnceBoundContext.associate(Object)has been called, further calls toBoundContext.associate(Object)will be ignored, until the context has been subsequentlyBoundContext.dissociate(Object)from the storage.- Specified by:
associatein interfaceBoundContext<R>- Parameters:
request- the external storage- Returns:
- true if the storage was attached, otherwise false
-
dissociate
Description copied from interface:BoundContextDissociate the context from the storage (for this thread). The context will only dissociate from the same storage it associated with.- Specified by:
dissociatein interfaceBoundContext<R>- Overrides:
dissociatein classAbstractBoundContext<R>- Parameters:
request- the external storage- Returns:
- true if the storage was dissociated
-
copyConversationIdGeneratorAndConversationsToSession
protected void copyConversationIdGeneratorAndConversationsToSession() -
sessionCreated
public void sessionCreated() -
associateRequestWithNewConversation
protected void associateRequestWithNewConversation() -
associateRequest
-
activate
public void activate()Description copied from interface:ManagedContextActivate the Context.- Specified by:
activatein interfaceConversationContext- Specified by:
activatein interfaceManagedContext- Overrides:
activatein classAbstractBoundContext<R>
-
activate
Description copied from interface:ConversationContextActivate the conversation context, using the id provided to attempt to restore a long-running conversation- Specified by:
activatein interfaceConversationContext- Parameters:
cid- if the cid is null, a transient conversation will be created, otherwise the conversation will be restored
-
initialize
-
deactivate
public void deactivate()Description copied from interface:ManagedContextDeactivate the Context, destroying any instances if the context is invalid.- Specified by:
deactivatein interfaceManagedContext- Overrides:
deactivatein classAbstractBoundContext<R>
-
conversationPromotedToLongRunning
-
invalidate
public void invalidate()Description copied from interface:ManagedContextMark the context as due for destruction when deactivate is called.- Specified by:
invalidatein interfaceConversationContext- Specified by:
invalidatein interfaceManagedContext- Overrides:
invalidatein classAbstractManagedContext
-
destroy
-
destroyConversation
-
generateConversationId
Description copied from interface:ConversationContextGenerate a new, unique, conversation id- Specified by:
generateConversationIdin interfaceConversationContext- Returns:
- a new, unique conversation id
-
getConversationIdGenerator
-
getConversation
Description copied from interface:ConversationContextGet the conversation with the given id.- Specified by:
getConversationin interfaceConversationContext- Parameters:
id- the id of the conversation to get- Returns:
- the conversation, or null if no conversation is known
-
getConversations
Description copied from interface:ConversationContextGet conversations currently known to the context. This will include any non transient conversations, as well as any conversations which were previously long running and have been made transient during this request.- Specified by:
getConversationsin interfaceConversationContext- Returns:
- a collection containing the conversations
-
getCurrentConversation
Description copied from interface:ConversationContextGet a handle the current conversation (transient or otherwise).- Specified by:
getCurrentConversationin interfaceConversationContext- Returns:
- the current conversation
-
getScope
- Specified by:
getScopein interfacejakarta.enterprise.context.spi.Context
-
setSessionAttribute
Set an attribute in the session.- Parameters:
request- the request to set the session attribute inname- the name of the attributevalue- the value of the attributecreate- if false, the attribute will only be set if the session already exists, otherwise it will always be set- Throws:
IllegalStateException- if create is true, and the session can't be created
-
getSessionAttribute
Get an attribute value from the session.- Parameters:
request- the request to get the session attribute fromname- the name of the attributecreate- if false, the attribute will only be retrieved if the session already exists, other wise it will always be retrieved- Returns:
- attribute
- Throws:
IllegalStateException- if create is true, and the session can't be created
-
getSessionAttributeFromSession
Get an attribute value from the session.- Parameters:
session- the session to get the session attribute fromname- the name of the attribute- Returns:
- attribute
- Throws:
IllegalStateException- if create is true, and the session can't be created
-
removeRequestAttribute
Remove an attribute from the request.- Parameters:
request- the request to remove the attribute fromname- the name of the attribute
-
setRequestAttribute
Set an attribute in the request.- Parameters:
request- the request to set the attribute fromname- the name of the attributevalue- the value of the attribute
-
getRequestAttribute
Retrieve an attribute value from the request- Parameters:
request- the request to get the attribute fromname- the name of the attribute to get- Returns:
- the value of the attribute
-
createRequestBeanStore
-
createSessionBeanStore
-
getSessionFromRequest
-
getNamingSchemePrefix
-
isAssociated
protected boolean isAssociated()Check if the context is currently associated- Returns:
- true if the context is associated
-
getRequest
Get the associated store- Returns:
- the request
-
getSessionAttributeNames
-