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
,org.jboss.weld.context.BoundContext<R>
,org.jboss.weld.context.ConversationContext
,org.jboss.weld.context.ManagedContext
,org.jboss.weld.context.WeldAlterableContext
- Direct Known Subclasses:
BoundConversationContextImpl
public abstract class AbstractConversationContext<R,S> extends AbstractBoundContext<R> implements org.jboss.weld.context.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 Modifier and Type Field Description static String
CONVERSATIONS_ATTRIBUTE_NAME
static String
DESTRUCTION_QUEUE_ATTRIBUTE_NAME
-
Constructor Summary
Constructors Constructor Description AbstractConversationContext(String contextId, org.jboss.weld.bootstrap.api.ServiceRegistry services)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
activate()
void
activate(String cid)
boolean
associate(R request)
protected void
associateRequest(org.jboss.weld.context.ManagedConversation conversation)
protected void
associateRequestWithNewConversation()
void
conversationPromotedToLongRunning(ConversationImpl conversation)
protected void
copyConversationIdGeneratorAndConversationsToSession()
protected abstract BoundBeanStore
createRequestBeanStore(NamingScheme namingScheme, R request)
protected abstract BoundBeanStore
createSessionBeanStore(NamingScheme namingScheme, S session)
void
deactivate()
boolean
destroy(S session)
protected void
destroyConversation(S session, String id, boolean fireEvents)
boolean
dissociate(R request)
String
generateConversationId()
long
getConcurrentAccessTimeout()
org.jboss.weld.context.ManagedConversation
getConversation(String id)
protected ConversationIdGenerator
getConversationIdGenerator()
Collection<org.jboss.weld.context.ManagedConversation>
getConversations()
org.jboss.weld.context.ManagedConversation
getCurrentConversation()
long
getDefaultTimeout()
protected abstract String
getNamingSchemePrefix()
String
getParameterName()
protected R
getRequest()
Get the associated storeprotected abstract Object
getRequestAttribute(R request, String name)
Retrieve an attribute value from the requestClass<? extends Annotation>
getScope()
protected abstract Object
getSessionAttribute(R request, String name, boolean create)
Get an attribute value from the session.protected abstract Object
getSessionAttributeFromSession(S session, String name)
Get an attribute value from the session.protected abstract Iterator<String>
getSessionAttributeNames(S session)
protected abstract S
getSessionFromRequest(R request, boolean create)
protected void
initialize(String cid)
void
invalidate()
protected boolean
isAssociated()
Check if the context is currently associatedprotected abstract void
removeRequestAttribute(R request, String name)
Remove an attribute from the request.void
sessionCreated()
void
setConcurrentAccessTimeout(long timeout)
void
setDefaultTimeout(long timeout)
void
setParameterName(String cid)
protected abstract void
setRequestAttribute(R request, String name, Object value)
Set an attribute in the request.protected abstract void
setSessionAttribute(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, setBeanStore
-
Methods inherited from class org.jboss.weld.contexts.AbstractManagedContext
isActive, isValid, removeState, setActive
-
Methods inherited from class org.jboss.weld.contexts.AbstractContext
checkContextInitialized, destroy, destroy, get, get, getContextual, getId, getServiceRegistry, isMultithreaded
-
-
-
-
Constructor Detail
-
AbstractConversationContext
public AbstractConversationContext(String contextId, org.jboss.weld.bootstrap.api.ServiceRegistry services)
-
-
Method Detail
-
getParameterName
public String getParameterName()
- Specified by:
getParameterName
in interfaceorg.jboss.weld.context.ConversationContext
-
setParameterName
public void setParameterName(String cid)
- Specified by:
setParameterName
in interfaceorg.jboss.weld.context.ConversationContext
-
setConcurrentAccessTimeout
public void setConcurrentAccessTimeout(long timeout)
- Specified by:
setConcurrentAccessTimeout
in interfaceorg.jboss.weld.context.ConversationContext
-
getConcurrentAccessTimeout
public long getConcurrentAccessTimeout()
- Specified by:
getConcurrentAccessTimeout
in interfaceorg.jboss.weld.context.ConversationContext
-
setDefaultTimeout
public void setDefaultTimeout(long timeout)
- Specified by:
setDefaultTimeout
in interfaceorg.jboss.weld.context.ConversationContext
-
getDefaultTimeout
public long getDefaultTimeout()
- Specified by:
getDefaultTimeout
in interfaceorg.jboss.weld.context.ConversationContext
-
associate
public boolean associate(R request)
- Specified by:
associate
in interfaceorg.jboss.weld.context.BoundContext<R>
-
dissociate
public boolean dissociate(R request)
- Specified by:
dissociate
in interfaceorg.jboss.weld.context.BoundContext<R>
- Overrides:
dissociate
in classAbstractBoundContext<R>
-
copyConversationIdGeneratorAndConversationsToSession
protected void copyConversationIdGeneratorAndConversationsToSession()
-
sessionCreated
public void sessionCreated()
-
associateRequestWithNewConversation
protected void associateRequestWithNewConversation()
-
associateRequest
protected void associateRequest(org.jboss.weld.context.ManagedConversation conversation)
-
activate
public void activate()
- Specified by:
activate
in interfaceorg.jboss.weld.context.ConversationContext
- Specified by:
activate
in interfaceorg.jboss.weld.context.ManagedContext
- Overrides:
activate
in classAbstractBoundContext<R>
-
activate
public void activate(String cid)
- Specified by:
activate
in interfaceorg.jboss.weld.context.ConversationContext
-
initialize
protected void initialize(String cid)
-
deactivate
public void deactivate()
- Specified by:
deactivate
in interfaceorg.jboss.weld.context.ManagedContext
- Overrides:
deactivate
in classAbstractBoundContext<R>
-
conversationPromotedToLongRunning
public void conversationPromotedToLongRunning(ConversationImpl conversation)
-
invalidate
public void invalidate()
- Specified by:
invalidate
in interfaceorg.jboss.weld.context.ConversationContext
- Specified by:
invalidate
in interfaceorg.jboss.weld.context.ManagedContext
- Overrides:
invalidate
in classAbstractManagedContext
-
destroy
public boolean destroy(S session)
-
generateConversationId
public String generateConversationId()
- Specified by:
generateConversationId
in interfaceorg.jboss.weld.context.ConversationContext
-
getConversationIdGenerator
protected ConversationIdGenerator getConversationIdGenerator()
-
getConversation
public org.jboss.weld.context.ManagedConversation getConversation(String id)
- Specified by:
getConversation
in interfaceorg.jboss.weld.context.ConversationContext
-
getConversations
public Collection<org.jboss.weld.context.ManagedConversation> getConversations()
- Specified by:
getConversations
in interfaceorg.jboss.weld.context.ConversationContext
-
getCurrentConversation
public org.jboss.weld.context.ManagedConversation getCurrentConversation()
- Specified by:
getCurrentConversation
in interfaceorg.jboss.weld.context.ConversationContext
-
getScope
public Class<? extends Annotation> getScope()
- Specified by:
getScope
in interfacejakarta.enterprise.context.spi.Context
-
setSessionAttribute
protected abstract void setSessionAttribute(R request, String name, Object value, boolean create)
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
protected abstract Object getSessionAttribute(R request, String name, boolean create)
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
protected abstract Object getSessionAttributeFromSession(S session, String name)
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
protected abstract void removeRequestAttribute(R request, String name)
Remove an attribute from the request.- Parameters:
request
- the request to remove the attribute fromname
- the name of the attribute
-
setRequestAttribute
protected abstract void setRequestAttribute(R request, String name, Object value)
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
protected abstract Object getRequestAttribute(R request, String name)
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
protected abstract BoundBeanStore createRequestBeanStore(NamingScheme namingScheme, R request)
-
createSessionBeanStore
protected abstract BoundBeanStore createSessionBeanStore(NamingScheme namingScheme, S session)
-
getNamingSchemePrefix
protected abstract String getNamingSchemePrefix()
-
isAssociated
protected boolean isAssociated()
Check if the context is currently associated- Returns:
- true if the context is associated
-
getRequest
protected R getRequest()
Get the associated store- Returns:
- the request
-
-