public abstract class AbstractConversationContext<R,S> extends AbstractBoundContext<R> implements ConversationContext
Modifier and Type | Field and Description |
---|---|
static String |
CONVERSATIONS_ATTRIBUTE_NAME |
Constructor and Description |
---|
AbstractConversationContext() |
Modifier and Type | Method and Description |
---|---|
void |
activate()
Activate the Context.
|
void |
activate(String cid)
Activate the conversation context, using the id provided to attempt to restore a long-running conversation
|
boolean |
associate(R request)
Associate the context with the storage (for this thread).
|
protected void |
associateRequest() |
protected void |
associateRequest(String cid) |
protected abstract BoundBeanStore |
createRequestBeanStore(NamingScheme namingScheme,
R request) |
protected abstract BoundBeanStore |
createSessionBeanStore(NamingScheme namingScheme,
S session) |
void |
deactivate()
Deactivate the Context, destroying any instances if the context is invalid.
|
boolean |
destroy(S session) |
protected void |
destroyConversation(S session,
String id) |
boolean |
dissociate(R request)
Dissociate the context from the storage (for this thread).
|
String |
generateConversationId()
Generate a new, unique, conversation id
|
long |
getConcurrentAccessTimeout()
Get the current concurrent access timeout
|
ManagedConversation |
getConversation(String id)
Get the conversation with the given id.
|
Collection<ManagedConversation> |
getConversations()
Get conversations currently known to the context.
|
ManagedConversation |
getCurrentConversation()
Get a handle the current conversation (transient or otherwise).
|
long |
getDefaultTimeout()
Get the default inactivity timeout.
|
String |
getParameterName()
Get the name of the parameter used to propagate the conversation id
|
protected abstract Object |
getRequestAttribute(R request,
String name)
Retrieve an attribute value from the request
|
Class<? extends Annotation> |
getScope()
Get the scope type of the context object.
|
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 S |
getSessionFromRequest(R request,
boolean create) |
void |
invalidate()
Mark the context as due for destruction when deactivate is called.
|
protected abstract void |
removeRequestAttribute(R request,
String name)
Remove an attribute from the request.
|
void |
setConcurrentAccessTimeout(long timeout)
Set the concurrent access timeout
|
void |
setDefaultTimeout(long timeout)
Set the default inactivity timeout.
|
void |
setParameterName(String cid)
Set the name of the parameter used to propagate the conversation id
|
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.
|
cleanup, getBeanStore, setBeanStore
isActive, isValid, setActive
destroy, destroy, get, get, getContextual, getId, getServiceRegistry
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
destroy
public static final String CONVERSATIONS_ATTRIBUTE_NAME
public String getParameterName()
ConversationContext
getParameterName
in interface ConversationContext
public void setParameterName(String cid)
ConversationContext
setParameterName
in interface ConversationContext
cid
- the name of the conversation id parameterpublic void setConcurrentAccessTimeout(long timeout)
ConversationContext
setConcurrentAccessTimeout
in interface ConversationContext
timeout
- the timeout (in ms) for the concurrent access lockpublic long getConcurrentAccessTimeout()
ConversationContext
getConcurrentAccessTimeout
in interface ConversationContext
public void setDefaultTimeout(long timeout)
ConversationContext
Conversation.setTimeout(long)
setDefaultTimeout
in interface ConversationContext
timeout
- the default inactivity timeout (in ms)public long getDefaultTimeout()
ConversationContext
getDefaultTimeout
in interface ConversationContext
public boolean associate(R request)
BoundContext
BoundContext.associate(Object)
has been called, further calls
to BoundContext.associate(Object)
will be ignored, until the context has been subsequently BoundContext.dissociate(Object)
from
the storage.associate
in interface BoundContext<R>
request
- the external storagepublic boolean dissociate(R request)
BoundContext
dissociate
in interface BoundContext<R>
dissociate
in class AbstractBoundContext<R>
request
- the external storagepublic void activate()
ManagedContext
activate
in interface ConversationContext
activate
in interface ManagedContext
activate
in class AbstractBoundContext<R>
protected void associateRequest()
protected void associateRequest(String cid)
public void activate(String cid)
ConversationContext
activate
in interface ConversationContext
cid
- if the cid is null, a transient conversation will be created, otherwise the conversation will be restoredpublic void deactivate()
ManagedContext
deactivate
in interface ManagedContext
deactivate
in class AbstractBoundContext<R>
public void invalidate()
ManagedContext
invalidate
in interface ConversationContext
invalidate
in interface ManagedContext
invalidate
in class AbstractManagedContext
public boolean destroy(S session)
public String generateConversationId()
ConversationContext
generateConversationId
in interface ConversationContext
public ManagedConversation getConversation(String id)
ConversationContext
getConversation
in interface ConversationContext
id
- the id of the conversation to getpublic Collection<ManagedConversation> getConversations()
ConversationContext
getConversations
in interface ConversationContext
public ManagedConversation getCurrentConversation()
ConversationContext
getCurrentConversation
in interface ConversationContext
public Class<? extends Annotation> getScope()
Context
protected abstract void setSessionAttribute(R request, String name, Object value, boolean create)
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, other wise it will always be setIllegalStateException
- if create is true, and the session can't be
createdprotected abstract Object getSessionAttribute(R request, String name, boolean create)
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 retrievedIllegalStateException
- if create is true, and the session can't be
createdprotected abstract Object getSessionAttributeFromSession(S session, String name)
session
- the session to get the session attribute fromname
- the name of the attributeIllegalStateException
- if create is true, and the session can't be
createdprotected abstract void removeRequestAttribute(R request, String name)
request
- the request to remove the attribute fromname
- the name of the attributeprotected abstract void setRequestAttribute(R request, String name, Object value)
request
- the request to set the attribute fromname
- the name of the attributevalue
- the value of the attributeprotected abstract Object getRequestAttribute(R request, String name)
request
- the request to get the attribute fromname
- the name of the attribute to getprotected abstract BoundBeanStore createRequestBeanStore(NamingScheme namingScheme, R request)
protected abstract BoundBeanStore createSessionBeanStore(NamingScheme namingScheme, S session)
Copyright © 2013 Seam Framework. All Rights Reserved.