|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.springframework.conversation.manager.DefaultConversation
public class DefaultConversation
The default implementation of the Conversation and MutableConversation interfaces.
This default implementation is also used within the AbstractConversationRepository.
The implementation supports destruction callbacks for attributes. The conversation object is serializable as long as all of its attributes are serializable as well.
| Constructor Summary | |
|---|---|
DefaultConversation()
|
|
| Method Summary | |
|---|---|
void |
addChildConversation(MutableConversation conversation,
boolean isIsolated)
Method being invoked to add the given conversation as a child conversation to this parent conversation. |
protected void |
checkValidity()
|
void |
clear()
Clears the state of this conversation by removing all of its attributes. |
Object |
getAttribute(String name)
Considers the internal attribute map as well as the map from the parent, if this is a nested conversation and only if it is not isolated. |
List<? extends Conversation> |
getChildren()
Returns a list of child conversations, if any, an empty list otherwise, must never return null. |
long |
getCreationTime()
Returns the timestamp in milliseconds this conversation has been created. |
String |
getId()
Returns the id of this conversation which must be unique within the scope it is used to identify the conversation object. |
long |
getLastAccessedTime()
Returns the timestamp in milliseconds this conversation was last accessed (usually through a Conversation.getAttribute(String), Conversation.setAttribute(String, Object) or Conversation.removeAttribute(String) access). |
Conversation |
getParent()
Returns the parent conversation, if this is a nested conversation, null otherwise. |
Conversation |
getRoot()
Returns the top level root conversation, if this is a nested conversation or this conversation, if it is the top level root conversation. |
int |
getTimeout()
Always returns the timeout value being set on the root as the root conversation is responsible for the timeout management. |
void |
invalidate()
Invalidates this conversation object. |
boolean |
isExpired()
Return true if the top root conversation has expired as the timeout is only tracked on the
root conversation. |
boolean |
isIsolated()
Returns true, if this is a nested, isolated conversation so that it does not inherit the state from its
parent but rather has its own state. |
boolean |
isNested()
Returns true, if this is a nested conversation and hence Conversation.getParent() will returns a non-null
value. |
boolean |
isParent()
|
void |
registerDestructionCallback(String name,
Runnable callback)
Registers the given callback to be invoked if the attribute having the specified name is being removed from this conversation. |
Object |
removeAttribute(String name)
Removes the value in the current conversation having the given name and returns it, if found and removed, null otherwise.Removes the attribute from this specific conversation, does not remove it, if found within its parent. |
void |
removeChildConversation(MutableConversation conversation)
Removes the given child conversation from this parent conversation. |
protected void |
removeParent()
|
Object |
setAttribute(String name,
Object value)
Stores the given value in this conversation using the specified name. |
void |
setId(String id)
Set the id for this conversation which must be unique within the scope the conversation objects are being stored. |
protected void |
setParentConversation(MutableConversation parentConversation,
boolean isIsolated)
|
void |
setTimeout(int timeout)
The timeout will be set on the root only. |
void |
touch()
Reset the last access timestamp using the current time in milliseconds from the system. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DefaultConversation()
| Method Detail |
|---|
public Object getAttribute(String name)
getAttribute in interface Conversationname - the name of the value to be retrieved
null otherwise
public Object setAttribute(String name,
Object value)
Conversationnull otherwise.
setAttribute in interface Conversationname - the name of the value to be stored in this conversationvalue - the value to be stored
null otherwisepublic Object removeAttribute(String name)
Conversationnull otherwise.
removeAttribute in interface Conversationname - the name of the value to be removed from this conversation
null otherwisepublic void clear()
MutableConversationConversationRepository supports destruction callbacks.
clear in interface MutableConversationpublic void setId(String id)
MutableConversationConversationRepository.
setId in interface MutableConversationid - the id of the conversationpublic String getId()
ConversationConversationRepository and most
likely be used by the ConversationResolver in order to manage
the current conversation.
getId in interface Conversationpublic Conversation getRoot()
Conversationnull.
getRoot in interface Conversationpublic Conversation getParent()
Conversationnull otherwise.
getParent in interface Conversationnull otherwisepublic List<? extends Conversation> getChildren()
Conversationnull.
getChildren in interface Conversationnull)
protected void setParentConversation(MutableConversation parentConversation,
boolean isIsolated)
public void addChildConversation(MutableConversation conversation,
boolean isIsolated)
MutableConversationisIsolated is true, the state of the child conversation is isolated from its parent
state, if it is set to false, the child conversation will inherit the state from its parent.
addChildConversation in interface MutableConversationconversation - the conversation to be added as a child to this parent conversationisIsolated - flag indicating whether this conversation should be isolated from the given parent conversationpublic void removeChildConversation(MutableConversation conversation)
MutableConversation
removeChildConversation in interface MutableConversationconversation - the conversation to be removed from this oneprotected void removeParent()
public boolean isNested()
Conversationtrue, if this is a nested conversation and hence Conversation.getParent() will returns a non-null
value.
isNested in interface Conversationtrue, if this is a nested conversation, false otherwisepublic boolean isParent()
public boolean isIsolated()
Conversationtrue, if this is a nested, isolated conversation so that it does not inherit the state from its
parent but rather has its own state. See ConversationType.ISOLATED for more details.
isIsolated in interface Conversationtrue, if this is a nested, isolated conversationpublic int getTimeout()
getTimeout in interface Conversation0 otherwisepublic void setTimeout(int timeout)
setTimeout in interface Conversationtimeout - the timeout in seconds to set, 0 for no timeoutpublic long getCreationTime()
Conversation
getCreationTime in interface Conversationpublic long getLastAccessedTime()
ConversationConversation.getAttribute(String), Conversation.setAttribute(String, Object) or Conversation.removeAttribute(String) access).
getLastAccessedTime in interface Conversationpublic void invalidate()
MutableConversationIllegalStateException,
if it is accessed or modified.
invalidate in interface MutableConversationprotected void checkValidity()
public boolean isExpired()
true if the top root conversation has expired as the timeout is only tracked on the
root conversation.
isExpired in interface MutableConversationtrue if the root of this conversation has been expiredpublic void touch()
MutableConversation
touch in interface MutableConversation
public void registerDestructionCallback(String name,
Runnable callback)
MutableConversationConversationRepository, so
this operation is optional and might not be supported.
registerDestructionCallback in interface MutableConversationname - the name of the attribute to register the destruction callback forcallback - the callback to be invoked if the specified attribute is removed from this conversation
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||