Skip to content

Commit 21e9bfd

Browse files
author
Micha Kiener
committed
SPR-6423, conversation object
1 parent 4d69729 commit 21e9bfd

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

org.springframework.context/src/main/java/org/springframework/conversation/Conversation.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@ public interface Conversation {
5454
*/
5555
void end(ConversationEndingType endingType);
5656

57+
/**
58+
* If this is a switched conversation (was created through
59+
* {@link JoinMode#SWITCHED}, this method might be used to make this
60+
* conversation the active one. If there is a current one active which is
61+
* not switched, it is ended, if the current one is also a switched one, it
62+
* is deactivated, but not ended. Invoking this method has the same effect
63+
* as {@link ConversationManager#switchConversation(String)}.
64+
*/
65+
void switchTo();
66+
5767
/**
5868
* Stores the given value in this conversation using the specified name. If
5969
* this state already contains a value attached to the given name, it is
@@ -167,6 +177,17 @@ public interface Conversation {
167177
*/
168178
boolean isNested();
169179

180+
/**
181+
* Returns <code>true</code>, if this is a switched conversation. A switched
182+
* conversation must be ended explicitly as it is not ended implicitly by
183+
* creating a new one for instance, however, if there is a timeout being
184+
* specified and a switched conversation is not used, it is ended
185+
* implicitly, otherwise you have to end a switched conversation manually.
186+
*
187+
* @return <code>true</code>, if this is a switched conversation
188+
*/
189+
boolean isSwtiched();
190+
170191
/**
171192
* Returns <code>true</code>, if this is a nested, isolated conversation so
172193
* that it does not inherit the state from its parent but rather has its own

org.springframework.context/src/main/java/org/springframework/conversation/manager/ConversationImpl.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ public class ConversationImpl extends DestructionAwareAttributeMap implements Mu
6969
*/
7070
private boolean isolated;
7171

72+
/** Flag, indicating whether this is a switched conversation. */
73+
private boolean switched;
74+
7275
/**
7376
* The join count which is increased on the joining method and decreased on
7477
* the end method.
@@ -164,6 +167,13 @@ public void begin() {
164167
temporary = false;
165168
}
166169

170+
/**
171+
* @see org.springframework.conversation.Conversation#switchTo()
172+
*/
173+
public void switchTo() {
174+
manager.switchConversation(getId());
175+
}
176+
167177
/**
168178
* Is just delegated to
169179
* {@link ConversationManager#endConversation(Conversation, ConversationEndingType)}
@@ -336,6 +346,13 @@ public boolean isIsolated() {
336346
return isolated;
337347
}
338348

349+
/**
350+
* @see org.springframework.conversation.Conversation#isSwtiched()
351+
*/
352+
public boolean isSwtiched() {
353+
return switched;
354+
}
355+
339356
/**
340357
* @see org.springframework.conversation.Conversation#isEnded()
341358
*/

0 commit comments

Comments
 (0)