Package org.jboss.weld.context
Interface ConversationContext
-
- All Superinterfaces:
jakarta.enterprise.context.spi.AlterableContext,jakarta.enterprise.context.spi.Context,ManagedContext,WeldAlterableContext
- All Known Subinterfaces:
BoundConversationContext,HttpConversationContext
public interface ConversationContext extends ManagedContext
The built in conversation context is associated with
ConversationScoped. It can be activated, invalidated and deactivated. and provides various options for configuring conversation defaults.Weld comes with two implementation of the conversation context. The
HttpConversationContext, in which conversations are bound to theHttpSession, can be injected:@ Inject @ Http ConversationContext conversationContext;
Alternatively the
BoundConversationContextin which conversations are bound aBoundRequestcan be injected:@ Inject @ Bound ConversationContext conversationContext;
- Author:
- Pete Muir
- See Also:
BoundConversationContext,HttpConversationContext,ConversationScoped
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidactivate()Activate the conversation context, starting a new transient conversationvoidactivate(String cid)Activate the conversation context, using the id provided to attempt to restore a long-running conversationStringgenerateConversationId()Generate a new, unique, conversation idlonggetConcurrentAccessTimeout()Get the current concurrent access timeoutManagedConversationgetConversation(String id)Get the conversation with the given id.Collection<ManagedConversation>getConversations()Get conversations currently known to the context.ManagedConversationgetCurrentConversation()Get a handle the current conversation (transient or otherwise).longgetDefaultTimeout()Get the default inactivity timeout.StringgetParameterName()Get the name of the parameter used to propagate the conversation idvoidinvalidate()Cause any expired conversations to be ended, and therefore marked for destruction when deactivate is called.voidsetConcurrentAccessTimeout(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 id-
Methods inherited from interface jakarta.enterprise.context.spi.Context
get, get, getScope, isActive
-
Methods inherited from interface org.jboss.weld.context.ManagedContext
deactivate
-
Methods inherited from interface org.jboss.weld.context.WeldAlterableContext
clearAndSet, getAllContextualInstances
-
-
-
-
Method Detail
-
invalidate
void invalidate()
Cause any expired conversations to be ended, and therefore marked for destruction when deactivate is called.- Specified by:
invalidatein interfaceManagedContext- Throws:
IllegalStateException- if the context is unable to access the underlying data store
-
activate
void activate(String cid)
Activate the conversation context, using the id provided to attempt to restore a long-running conversation- Parameters:
cid- if the cid is null, a transient conversation will be created, otherwise the conversation will be restored- Throws:
IllegalStateException- if the context is unable to access the underlying data store
-
activate
void activate()
Activate the conversation context, starting a new transient conversation- Specified by:
activatein interfaceManagedContext- Throws:
IllegalStateException- if the context is unable to access the underlying data store
-
setParameterName
void setParameterName(String cid)
Set the name of the parameter used to propagate the conversation id- Parameters:
cid- the name of the conversation id parameter
-
getParameterName
String getParameterName()
Get the name of the parameter used to propagate the conversation id- Returns:
- the name of the conversation id parameter
-
setConcurrentAccessTimeout
void setConcurrentAccessTimeout(long timeout)
Set the concurrent access timeout- Parameters:
timeout- the timeout (in ms) for the concurrent access lock
-
getConcurrentAccessTimeout
long getConcurrentAccessTimeout()
Get the current concurrent access timeout- Returns:
- the timeout (in ms) for the concurrent access lock
-
setDefaultTimeout
void setDefaultTimeout(long timeout)
Set the default inactivity timeout. This may be overridden on a per conversation basis usingConversation.setTimeout(long)- Parameters:
timeout- the default inactivity timeout (in ms)
-
getDefaultTimeout
long getDefaultTimeout()
Get the default inactivity timeout. This may have been overridden on a per conversation basis.- Returns:
- the default inactivity timeout (in ms)
-
getConversations
Collection<ManagedConversation> getConversations()
Get 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.- Returns:
- a collection containing the conversations
- Throws:
IllegalStateException- if the context is unable to access the underlying data store
-
getConversation
ManagedConversation getConversation(String id)
Get the conversation with the given id.- Parameters:
id- the id of the conversation to get- Returns:
- the conversation, or null if no conversation is known
- Throws:
IllegalStateException- if the context is unable to access the underlying data store
-
generateConversationId
String generateConversationId()
Generate a new, unique, conversation id- Returns:
- a new, unique conversation id
- Throws:
IllegalStateException- if the context is unable to access the underlying data store
-
getCurrentConversation
ManagedConversation getCurrentConversation()
Get a handle the current conversation (transient or otherwise).- Returns:
- the current conversation
- Throws:
IllegalStateException- if the context is unable to access the underlying data store
-
-