|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ContextManager
Interface for Context
management including lifecyle and storage.
Note that particular care must be taken when using this interface in a
clustered environment! Non-clustered implementations (MemoryContextManager
in particular) allow direct changes to Context
objects returned by
applicable methods. However, in clustered environments, these changes will
not be propagated to the distributed cache unless an explicit call is made to
updateContext(Context context)
.
For example, if you were to do this:
ContextManager manager = getContextManager(); Context parent = manager.begin(); Context child = manager.begin(parent); ... String parentId = parent.getContextIdentifier(); Context reloadedParent = manager.getContext(parentId);The parent object reference and the reloadedParent object reference would have object equality, but not reference equality. That is:
(parent == reloadedParent)would evaluate to false; however:
(parent.equals(reloadedParent))would evaluate to true. To be safe, users of this interface should take care to appropriately use
updateContext(Context context)
.
Field Summary | |
---|---|
static long |
DEFAULT_TIMEOUT
The default timeout for new context instances. |
static long |
ETERNITY
Value used to indicate an eternal context. |
static java.lang.String |
LOCAL_ID
Valud used as the identifier for local context instances. |
Method Summary | |
---|---|
void |
addContextListener(ContextListener listener)
Adds a context lifecycle listener to the manager. |
Context |
begin()
Mark the beginning of a business activity by creating a new context instance with the default timeout. |
Context |
begin(Context parentContext)
Mark the beginning of a new step in a existing business activity using the given context as the parent and the setting the timeout to the default value. |
Context |
begin(Context parentContext,
long timeout)
Mark the beginning of a new step in a existing business activity using the given context as the parent and the setting the timeout to specified value. |
Context |
begin(long timeout)
Mark the beginning of a business activity by creating a new context instance with the specified timeout. |
Context |
begin(java.lang.String parentContextId)
Mark the beginning of a new step in a existing business activity using the given context as the parent and the setting the timeout to the default value. |
Context |
begin(java.lang.String parentContextId,
long timeout)
Mark the beginning of a new step in a existing business activity using the given context as the parent and the setting the timeout to specified value. |
void |
completed(java.lang.String contextId)
Indicate that the business activity associated with the given context ID is complete. |
Context |
createLocalContext()
Creates a new local Context instance. |
Context |
getContext(java.lang.String contextId)
Gets the contents of the context specified by given ID. |
void |
removeContextListener(ContextListener listener)
Removes a context lifecycle listener from the manager. |
void |
updateContext(Context context)
Updates the contents of context identified by Context.getContextIdentifier() . |
void |
updateContextTimeout(java.lang.String contextId,
long timeout)
Updates the timout of the Context specified by the given Id. |
Field Detail |
---|
static final long DEFAULT_TIMEOUT
static final long ETERNITY
static final java.lang.String LOCAL_ID
Method Detail |
---|
Context createLocalContext()
Context
instance. Local contexts are not
uniquely identifiable by the context manager and can not be used for tracking purposes.
A local context can be used outside of the context manager for any other API that uses
context data, but does not rely on context status.
Context begin() throws ContextException
ContextException
- to signal a problem with context creationContext begin(long timeout) throws ContextException
timeout
- the timeout for the context in milliseconds
ContextException
- to signal a problem with context creationContext begin(Context parentContext) throws ContextException
parentContext
- the parent context instance to associate with the activity
ContextException
- to signal a problem with activity creationContext begin(Context parentContext, long timeout) throws ContextException
parentContext
- the parent context instance to associate with the activitytimeout
- the timeout for the context in milliseconds
ContextException
- to signal a problem with activity creationContext begin(java.lang.String parentContextId) throws ContextException
parentContextId
- the ID of the parent context instance to associate with the activity
ContextException
- to signal a problem with activity creationContext begin(java.lang.String parentContextId, long timeout) throws ContextException
parentContextId
- the ID of the parent context instance to associate with the activitytimeout
- the timeout for the context in milliseconds
ContextException
- to signal a problem with activity creationvoid completed(java.lang.String contextId) throws NoContextException, UnknownContextException
contextId
-
UnknownContextException
- to signal that the context is unrecognized by the manager
NoContextException
Context getContext(java.lang.String contextId) throws NoContextException, UnknownContextException
contextId
- the ID of the context to query
UnknownContextException
- to signal that the context is unrecognized by the manager
NoContextException
void updateContext(Context context) throws NoContextException, InvalidContextException, UnknownContextException
Context.getContextIdentifier()
.
This will fail if the context specified by contextId has active children.
context
- the udpated context
InvalidContextException
- to signal that the contents of the passed context are invalid
UnknownContextException
- to signal that the context is unrecognized by the manager
NoContextException
void updateContextTimeout(java.lang.String contextId, long timeout) throws InvalidContextException, UnknownContextException
contextId
- a non-null Id of the Context to updatetimeout
- the timeout for the Context in seconds
InvalidContextException
- to signal that the contents of the passed context are invalid
UnknownContextException
- to signal that the context is unrecognized by the managervoid addContextListener(ContextListener listener)
listener
- void removeContextListener(ContextListener listener)
listener
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |