提交 01522394 编写于 作者: M Micha Kiener

SPR-6423, conversation object

上级 bc998249
......@@ -21,6 +21,8 @@ import java.util.List;
import org.springframework.beans.factory.config.DestructionAwareAttributeMap;
import org.springframework.conversation.Conversation;
import org.springframework.conversation.ConversationActivationType;
import org.springframework.conversation.ConversationDeactivationType;
import org.springframework.conversation.ConversationEndingType;
import org.springframework.conversation.ConversationListener;
import org.springframework.conversation.JoinMode;
......@@ -159,6 +161,10 @@ public class ConversationImpl extends DestructionAwareAttributeMap implements Mu
}
/**
* Is just delegated to
* {@link ConversationManager#finalEndConversation(Conversation, ConversationEndingType)}
* .
*
* @see org.springframework.conversation.manager.MutableConversation#finalEnd(org.springframework.conversation.ConversationEndingType)
*/
public void finalEnd(ConversationEndingType endingType) {
......@@ -175,8 +181,18 @@ public class ConversationImpl extends DestructionAwareAttributeMap implements Mu
return;
}
// set the ended flag and flush the state
ended = true;
// invoke listeners, if any
List<ConversationListener> list = getListeners();
if (list != null) {
for (ConversationListener listener : list) {
listener.conversationEnded(this, endingType);
}
}
// flush the state of this conversation AFTER the listeners have been
// invoked as there could be some state still needed
clear();
}
......@@ -334,6 +350,38 @@ public class ConversationImpl extends DestructionAwareAttributeMap implements Mu
}
}
/**
* @see org.springframework.conversation.manager.MutableConversation#activated(org.springframework.conversation.ConversationActivationType,
* org.springframework.conversation.Conversation)
*/
public void activated(ConversationActivationType activationType, Conversation oldCurrentConversation) {
touch();
List<ConversationListener> list = getListeners();
if (list == null) {
return;
}
for (ConversationListener listener : list) {
listener.conversationActivated(this, oldCurrentConversation, activationType);
}
}
/**
* @see org.springframework.conversation.manager.MutableConversation#deactivated(org.springframework.conversation.ConversationDeactivationType,
* org.springframework.conversation.Conversation)
*/
public void deactivated(ConversationDeactivationType deactivationType, Conversation newCurrentConversation) {
touch();
List<ConversationListener> list = getListeners();
if (list == null) {
return;
}
for (ConversationListener listener : list) {
listener.conversationDeactivated(this, newCurrentConversation, deactivationType);
}
}
/**
* @see org.springframework.conversation.manager.MutableConversation#getListeners()
*/
......
......@@ -16,6 +16,8 @@
package org.springframework.conversation.manager;
import org.springframework.conversation.Conversation;
import org.springframework.conversation.ConversationActivationType;
import org.springframework.conversation.ConversationDeactivationType;
import org.springframework.conversation.ConversationEndingType;
/**
......@@ -127,4 +129,24 @@ public interface MutableConversation extends Conversation {
* scope and beans are being accessed or added to it.
*/
void touch();
/**
* Invoked by the conversation manager if this conversation was made active.
* The type qualifies how the this conversation was actually made active.
* This method must invoke any listeners registered to this conversation.
*
* @param activationType the type qualifying the activation
* @param oldCurrentConversation the old current conversation, if available,
* <code>null</code> otherwise
*/
void activated(ConversationActivationType activationType, Conversation oldCurrentConversation);
/**
* Invoked by the conversation manager if this conversation was deactivated.
* The type qualifies how the this conversation was deactivated.
*
* @param deactivationType the type qualifying the deactivation
* @param newCurrentConversation the conversation made the current one
*/
void deactivated(ConversationDeactivationType deactivationType, Conversation newCurrentConversation);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册