Package org.jboss.weld.context
Class AbstractConversationContext<R,S>
- java.lang.Object
-
- org.jboss.weld.context.AbstractContext
-
- org.jboss.weld.context.AbstractManagedContext
-
- org.jboss.weld.context.AbstractBoundContext<R>
-
- org.jboss.weld.context.AbstractConversationContext<R,S>
-
- All Implemented Interfaces:
javax.enterprise.context.spi.AlterableContext,javax.enterprise.context.spi.Context,org.jboss.weld.context.BoundContext<R>,org.jboss.weld.context.ConversationContext,org.jboss.weld.context.ManagedContext
- Direct Known Subclasses:
BoundConversationContextImpl,HttpConversationContextImpl
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 StringCONVERSATIONS_ATTRIBUTE_NAMEstatic StringDESTRUCTION_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 voidactivate()voidactivate(String cid)booleanassociate(R request)protected voidassociateRequest(org.jboss.weld.context.ManagedConversation conversation)protected voidassociateRequestWithNewConversation()voidconversationPromotedToLongRunning(ConversationImpl conversation)protected voidcopyConversationIdGeneratorAndConversationsToSession()protected abstract BoundBeanStorecreateRequestBeanStore(NamingScheme namingScheme, R request)protected abstract BoundBeanStorecreateSessionBeanStore(NamingScheme namingScheme, S session)voiddeactivate()booleandestroy(S session)protected voiddestroyConversation(S session, String id)booleandissociate(R request)StringgenerateConversationId()longgetConcurrentAccessTimeout()org.jboss.weld.context.ManagedConversationgetConversation(String id)protected ConversationIdGeneratorgetConversationIdGenerator()Collection<org.jboss.weld.context.ManagedConversation>getConversations()org.jboss.weld.context.ManagedConversationgetCurrentConversation()longgetDefaultTimeout()protected abstract StringgetNamingSchemePrefix()StringgetParameterName()protected RgetRequest()Get 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.protected abstract Iterator<String>getSessionAttributeNames(S session)protected abstract SgetSessionFromRequest(R request, boolean create)protected voidinitialize(String cid)voidinvalidate()protected booleanisAssociated()Check if the context is currently associatedprotected abstract voidremoveRequestAttribute(R request, String name)Remove an attribute from the request.voidsessionCreated()voidsetConcurrentAccessTimeout(long timeout)voidsetDefaultTimeout(long timeout)voidsetParameterName(String cid)protected 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.context.AbstractBoundContext
cleanup, getBeanStore, setBeanStore
-
Methods inherited from class org.jboss.weld.context.AbstractManagedContext
isActive, isValid, removeState, setActive
-
Methods inherited from class org.jboss.weld.context.AbstractContext
checkContextInitialized, destroy, destroy, get, get, getContextual, getId, getServiceRegistry
-
-
-
-
Constructor Detail
-
AbstractConversationContext
public AbstractConversationContext(String contextId, org.jboss.weld.bootstrap.api.ServiceRegistry services)
-
-
Method Detail
-
getParameterName
public String getParameterName()
- Specified by:
getParameterNamein interfaceorg.jboss.weld.context.ConversationContext
-
setParameterName
public void setParameterName(String cid)
- Specified by:
setParameterNamein interfaceorg.jboss.weld.context.ConversationContext
-
setConcurrentAccessTimeout
public void setConcurrentAccessTimeout(long timeout)
- Specified by:
setConcurrentAccessTimeoutin interfaceorg.jboss.weld.context.ConversationContext
-
getConcurrentAccessTimeout
public long getConcurrentAccessTimeout()
- Specified by:
getConcurrentAccessTimeoutin interfaceorg.jboss.weld.context.ConversationContext
-
setDefaultTimeout
public void setDefaultTimeout(long timeout)
- Specified by:
setDefaultTimeoutin interfaceorg.jboss.weld.context.ConversationContext
-
getDefaultTimeout
public long getDefaultTimeout()
- Specified by:
getDefaultTimeoutin interfaceorg.jboss.weld.context.ConversationContext
-
associate
public boolean associate(R request)
- Specified by:
associatein interfaceorg.jboss.weld.context.BoundContext<R>
-
dissociate
public boolean dissociate(R request)
- Specified by:
dissociatein interfaceorg.jboss.weld.context.BoundContext<R>- Overrides:
dissociatein 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:
activatein interfaceorg.jboss.weld.context.ConversationContext- Specified by:
activatein interfaceorg.jboss.weld.context.ManagedContext- Overrides:
activatein classAbstractBoundContext<R>
-
activate
public void activate(String cid)
- Specified by:
activatein interfaceorg.jboss.weld.context.ConversationContext
-
initialize
protected void initialize(String cid)
-
deactivate
public void deactivate()
- Specified by:
deactivatein interfaceorg.jboss.weld.context.ManagedContext- Overrides:
deactivatein classAbstractBoundContext<R>
-
conversationPromotedToLongRunning
public void conversationPromotedToLongRunning(ConversationImpl conversation)
-
invalidate
public void invalidate()
- Specified by:
invalidatein interfaceorg.jboss.weld.context.ConversationContext- Specified by:
invalidatein interfaceorg.jboss.weld.context.ManagedContext- Overrides:
invalidatein classAbstractManagedContext
-
destroy
public boolean destroy(S session)
-
generateConversationId
public String generateConversationId()
- Specified by:
generateConversationIdin interfaceorg.jboss.weld.context.ConversationContext
-
getConversationIdGenerator
protected ConversationIdGenerator getConversationIdGenerator()
-
getConversation
public org.jboss.weld.context.ManagedConversation getConversation(String id)
- Specified by:
getConversationin interfaceorg.jboss.weld.context.ConversationContext
-
getConversations
public Collection<org.jboss.weld.context.ManagedConversation> getConversations()
- Specified by:
getConversationsin interfaceorg.jboss.weld.context.ConversationContext
-
getCurrentConversation
public org.jboss.weld.context.ManagedConversation getCurrentConversation()
- Specified by:
getCurrentConversationin interfaceorg.jboss.weld.context.ConversationContext
-
getScope
public Class<? extends Annotation> getScope()
- Specified by:
getScopein interfacejavax.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
-
-