org.jboss.weld.context
Interface ConversationContext

All Superinterfaces:
javax.enterprise.context.spi.Context, ManagedContext
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 the HttpSession, can be injected:

 @Inject @Http ConversationContext conversationContext;
 

Alternatively the BoundConversationContext in which conversations are bound a BoundRequest can be injected:

 @Inject @Bound ConversationContext conversationContext;
 

Author:
Pete Muir
See Also:
BoundConversationContext, HttpConversationContext, ConversationScoped

Method Summary
 void activate()
          Activate the conversation context, starting a new transient conversation
 void activate(String cid)
          Activate the conversation context, using the id provided to attempt to restore a long-running conversation
 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
 void invalidate()
          Cause any expired conversations to be ended, and therefore marked for destruction when deactivate is called.
 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
 
Methods inherited from interface org.jboss.weld.context.ManagedContext
deactivate
 
Methods inherited from interface javax.enterprise.context.spi.Context
get, get, getScope, isActive
 

Method Detail

invalidate

void invalidate()
Cause any expired conversations to be ended, and therefore marked for destruction when deactivate is called.

Specified by:
invalidate in interface ManagedContext
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:
activate in interface ManagedContext
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 using Conversation.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


Copyright © 2013 Seam Framework. All Rights Reserved.