Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

SPR-6420, refactoring conversation scope for more simplicity

  • Loading branch information...
commit 92ff07de155c3c202bd8d5035923e860550b51f6 1 parent 5bfb99a
authored
3  org.springframework.context/src/main/java/org/springframework/conversation/Conversation.java
@@ -20,11 +20,10 @@
20 20
 import java.util.Map;
21 21
 
22 22
 import org.springframework.conversation.manager.ConversationManager;
23  
-import org.springframework.conversation.scope.ConversationScope;
24 23
 
25 24
 /**
26 25
  * The interface for a conversation, the instance behind the
27  
- * {@link ConversationScope}.<br/>
  26
+ * {@link org.springframework.conversation.scope.ConversationScope}.<br/>
28 27
  * Conversations are created through the {@link ConversationManager} which is
29 28
  * the main API for conversation management unless the annotations are used. See
30 29
  * {@link ConversationManager} for a more detailed description on how the
159  org.springframework.context/src/main/java/org/springframework/conversation/manager/ConversationManager.java
@@ -26,105 +26,68 @@
26 26
 import org.springframework.conversation.annotation.BeginConversation;
27 27
 import org.springframework.conversation.annotation.Conversational;
28 28
 import org.springframework.conversation.annotation.EndConversation;
29  
-import org.springframework.conversation.scope.ConversationScope;
30 29
 
31 30
 /**
32  
- * <p>
33  
- * The interface to be implemented by any conversation manager. It is used by
34  
- * the advice behind the conversational annotations like
35  
- * {@link BeginConversation}, {@link EndConversation} and {@link Conversational}
36  
- * but might be used for even fine grained access to the underlying conversation
37  
- * management, if a initializer callback is needed for instance or if
38  
- * conversation switching should be used. If used directly, the conversation
39  
- * manager can be injected into any bean to be used as it is a singleton and
40  
- * thread safe.<br/>
41  
- * 
42  
- * Conversations are a good way to scope beans and attributes depending on
43  
- * business logic boundary rather than a technical boundary of a scope like
44  
- * session, request etc. Usually a conversation boundary is defined by the
45  
- * starting point of a use case and ended accordingly or in other words a
46  
- * conversation defines the boundary for a unit of work.<br/>
47  
- * <br/>
48  
- * 
49  
- * Here is a short description on how to use the conversation management:<br/>
50  
- * <br/>
51  
- * <b>Starting a conversation</b><br/>
52  
- * A conversation can be started in two different ways, either by placing the
53  
- * {@link BeginConversation} annotation on a method defining the starting point
54  
- * of the conversation (use case) or by invoking
55  
- * {@link ConversationManager#beginConversation(boolean, JoinMode)} manually
56  
- * through the conversation manager. The {@link JoinMode} declares on how a new
57  
- * conversation is created (see its javadoc for more details on the different
58  
- * join modes).<br/>
59  
- * <br/>
60  
- * 
61  
- * <b>Ending a conversation</b><br/>
62  
- * A current conversation is ended by either placing the {@link EndConversation}
63  
- * annotation on the ending method or by manually invoke the
64  
- * {@link ConversationManager#endCurrentConversation(ConversationEndingType)}
65  
- * method. A current conversation might also be ended, if a new conversation is
66  
- * started having {@link JoinMode#NEW} being declared where the current
67  
- * conversation is ended silently and a new one is created. This might be the
68  
- * obvious way to end a conversation, if the end of a use case is not always
69  
- * forced to be invoked by a user.<br/>
70  
- * <br/>
71  
- * 
72  
- * <b>Temporary conversations</b><br/>
73  
- * A temporary conversation is automatically created, if the container is about
74  
- * to create a bean having conversation scope but there is no current
75  
- * conversation in progress, hence a new, temporary conversation is created. A
76  
- * temporary conversation might be turned into a long running one by joining it
77  
- * or manually invoke {@link Conversation#begin()}.<br/>
78  
- * <br/>
79  
- * 
80  
- * <b>Initializing the conversation</b><br/>
81  
- * If there is any need to initialize beans or entities while starting a new
82  
- * conversation, the {@link ConversationInitializationCallback} might be used to
83  
- * be invoked if the new conversation was started in order to initialize it.
84  
- * This is done by providing such a callback to the
85  
- * {@link ConversationManager#beginConversation(JoinMode, ConversationType, ConversationInitializationCallback...)}
86  
- * method. The callback feature is not available through the annotation support
87  
- * and hence is only available through the conversation manager API. Here is an
88  
- * example on such an initializing feature; if a conversation is used in
89  
- * conjunction of a JPA entity manager or Hibernate session, there might be
90  
- * entity beans already loaded, cached or referenced within backing beans which
91  
- * have to be merged into the entity manager or session in order to be used
92  
- * within the conversation's work. So it would be possible to implement the
93  
- * callback, merging the necessary entities used within the conversation into
94  
- * the entity manager.<br/>
95  
- * <br/>
96  
- * 
97  
- * <b>Listening to conversation events</b><br/>
98  
- * If there is a need to listening to events of a conversation, add yourself as
99  
- * a {@link ConversationListener} to a new {@link Conversation} as being
100  
- * returned by this {@link ConversationManager}. The same goal can be achieved
101  
- * by implementing the {@link ConversationListener} interface on a conversation
102  
- * scoped bean which will be registered automatically to receive events.<br/>
103  
- * <br/>
104  
- * 
105  
- * <b>Nesting conversations</b><br/>
106  
- * Conversations might be nested either by inheriting the state of the parent (
107  
- * {@link JoinMode#NESTED}) or by isolating its state from the parent (
108  
- * {@link JoinMode#ISOLATED}). Ending a nested conversation automatically
109  
- * switches back to its parent making it the current conversation.<br/>
110  
- * <br/>
111  
- * 
112  
- * <b>Where are conversations stored?</b><br/>
113  
- * Conversations are created by the {@link ConversationManager} and registered
114  
- * within the {@link ConversationScope}. The scope handler is injected into the
115  
- * manager by Spring (statically as both beans are singletons) and registered as
116  
- * a custom scope. As the scope handler is a singleton, it needs a store where
117  
- * conversations are stored within which is usually bound to the current session
118  
- * or window of a user and represented by the {@link ConversationStore}
119  
- * interface. The store is usually being injected into the scope handler using
120  
- * method injection as the store has a narrower scope than the scope handler. In
121  
- * a web environment, the store would typically live in session scope to
122  
- * separate the conversations from each of the sessions. There is always one
123  
- * current conversation either stored within the session or as a request
124  
- * parameter passed along every request to set the current conversation and is
125  
- * accessed by the manager using a {@link ConversationResolver}.
126  
- * </p>
127  
- * 
  31
+ * <p> The interface to be implemented by any conversation manager. It is used by the advice behind the conversational
  32
+ * annotations like {@link BeginConversation}, {@link EndConversation} and {@link Conversational} but might be used for
  33
+ * even fine grained access to the underlying conversation management, if a initializer callback is needed for instance
  34
+ * or if conversation switching should be used. If used directly, the conversation manager can be injected into any bean
  35
+ * to be used as it is a singleton and thread safe.<br/>
  36
+ *
  37
+ * Conversations are a good way to scope beans and attributes depending on business logic boundary rather than a
  38
+ * technical boundary of a scope like session, request etc. Usually a conversation boundary is defined by the starting
  39
+ * point of a use case and ended accordingly or in other words a conversation defines the boundary for a unit of
  40
+ * work.<br/> <br/>
  41
+ *
  42
+ * Here is a short description on how to use the conversation management:<br/> <br/> <b>Starting a conversation</b><br/>
  43
+ * A conversation can be started in two different ways, either by placing the {@link BeginConversation} annotation on a
  44
+ * method defining the starting point of the conversation (use case) or by invoking {@link
  45
+ * ConversationManager#beginConversation(boolean, JoinMode)} manually through the conversation manager. The {@link
  46
+ * JoinMode} declares on how a new conversation is created (see its javadoc for more details on the different join
  47
+ * modes).<br/> <br/>
  48
+ *
  49
+ * <b>Ending a conversation</b><br/> A current conversation is ended by either placing the {@link EndConversation}
  50
+ * annotation on the ending method or by manually invoke the {@link ConversationManager#endCurrentConversation(ConversationEndingType)}
  51
+ * method. A current conversation might also be ended, if a new conversation is started having {@link JoinMode#NEW}
  52
+ * being declared where the current conversation is ended silently and a new one is created. This might be the obvious
  53
+ * way to end a conversation, if the end of a use case is not always forced to be invoked by a user.<br/> <br/>
  54
+ *
  55
+ * <b>Temporary conversations</b><br/> A temporary conversation is automatically created, if the container is about to
  56
+ * create a bean having conversation scope but there is no current conversation in progress, hence a new, temporary
  57
+ * conversation is created. A temporary conversation might be turned into a long running one by joining it or manually
  58
+ * invoke {@link Conversation#begin()}.<br/> <br/>
  59
+ *
  60
+ * <b>Initializing the conversation</b><br/> If there is any need to initialize beans or entities while starting a new
  61
+ * conversation, the {@link ConversationInitializationCallback} might be used to be invoked if the new conversation was
  62
+ * started in order to initialize it. This is done by providing such a callback to the {@link
  63
+ * ConversationManager#beginConversation(JoinMode, ConversationType, ConversationInitializationCallback...)} method. The
  64
+ * callback feature is not available through the annotation support and hence is only available through the conversation
  65
+ * manager API. Here is an example on such an initializing feature; if a conversation is used in conjunction of a JPA
  66
+ * entity manager or Hibernate session, there might be entity beans already loaded, cached or referenced within backing
  67
+ * beans which have to be merged into the entity manager or session in order to be used within the conversation's work.
  68
+ * So it would be possible to implement the callback, merging the necessary entities used within the conversation into
  69
+ * the entity manager.<br/> <br/>
  70
+ *
  71
+ * <b>Listening to conversation events</b><br/> If there is a need to listening to events of a conversation, add
  72
+ * yourself as a {@link ConversationListener} to a new {@link Conversation} as being returned by this {@link
  73
+ * ConversationManager}. The same goal can be achieved by implementing the {@link ConversationListener} interface on a
  74
+ * conversation scoped bean which will be registered automatically to receive events.<br/> <br/>
  75
+ *
  76
+ * <b>Nesting conversations</b><br/> Conversations might be nested either by inheriting the state of the parent ( {@link
  77
+ * JoinMode#NESTED}) or by isolating its state from the parent ( {@link JoinMode#ISOLATED}). Ending a nested
  78
+ * conversation automatically switches back to its parent making it the current conversation.<br/> <br/>
  79
+ *
  80
+ * <b>Where are conversations stored?</b><br/> Conversations are created by the {@link ConversationManager} and
  81
+ * registered within the {@link org.springframework.conversation.scope.ConversationScope}. The scope handler is
  82
+ * injected into the manager by Spring (statically as both beans are singletons) and registered as a custom scope. As
  83
+ * the scope handler is a singleton, it needs a store where conversations are stored within which is usually bound to
  84
+ * the current session or window of a user and represented by the {@link ConversationStore} interface. The store is
  85
+ * usually being injected into the scope handler using method injection as the store has a narrower scope than the scope
  86
+ * handler. In a web environment, the store would typically live in session scope to separate the conversations from
  87
+ * each of the sessions. There is always one current conversation either stored within the session or as a request
  88
+ * parameter passed along every request to set the current conversation and is accessed by the manager using a {@link
  89
+ * ConversationResolver}. </p>
  90
+ *
128 91
  * @author Micha Kiener
129 92
  * @since 3.1
130 93
  */
@@ -132,7 +95,7 @@
132 95
 
133 96
 	/**
134 97
 	 * This method starts a new {@link Conversation} and registers it within the
135  
-	 * {@link ConversationScope} to be exposed as the current conversation.
  98
+	 * {@link org.springframework.conversation.scope.ConversationScope} to be exposed as the current conversation.
136 99
 	 * 
137 100
 	 * @param temporary flag indicating whether this new conversation is
138 101
 	 * temporary (if invoked from elsewhere as the scope, it should always be
194  org.springframework.context/src/main/java/org/springframework/conversation/scope/ConversationScope.java
@@ -15,35 +15,213 @@
15 15
  */
16 16
 package org.springframework.conversation.scope;
17 17
 
  18
+import org.springframework.beans.factory.ObjectFactory;
18 19
 import org.springframework.beans.factory.config.Scope;
  20
+import org.springframework.conversation.Conversation;
  21
+import org.springframework.conversation.JoinMode;
  22
+import org.springframework.conversation.manager.ConversationManager;
  23
+import org.springframework.conversation.manager.ConversationResolver;
  24
+import org.springframework.conversation.manager.ConversationStore;
  25
+import org.springframework.util.Assert;
19 26
 
20 27
 /**
21  
- * This interface is implemented by the conversation scope used to hold and
22  
- * expose conversation scoped beans. It will be registered as a custom scope
23  
- * within the application context.
  28
+ * The default implementation of the {@link ConversationScope} exposed as
  29
+ * <code>"conversation"</code> scope. It needs the {@link ConversationStore} and
  30
+ * the {@link ConversationResolver} to resolve and request the current
  31
+ * conversation where attributes are resolved with and registered in.
24 32
  * 
25 33
  * @author Micha Kiener
26 34
  * @since 3.1
27 35
  */
28  
-public interface ConversationScope extends Scope {
  36
+public class ConversationScope implements Scope {
29 37
 	/** The name of the scope being exposed within the application context. */
30 38
 	public static final String CONVERSATION_SCOPE_NAME = "conversation";
31 39
 
32 40
 	/**
33 41
 	 * The name of the contextual object for the conversation manager (see
34  
-	 * {@link Scope#resolveContextualObject(String)}).
  42
+	 * {@link org.springframework.beans.factory.config.Scope#resolveContextualObject(String)}).
35 43
 	 */
36 44
 	public static final String REFERENCE_CONVERSATION_MANAGER = "conversationManager";
37 45
 
38 46
 	/**
39 47
 	 * The name of the contextual object for the conversation store (see
40  
-	 * {@link Scope#resolveContextualObject(String)}).
  48
+	 * {@link org.springframework.beans.factory.config.Scope#resolveContextualObject(String)}).
41 49
 	 */
42 50
 	public static final String REFERENCE_CONVERSATION_STORE = "conversationStore";
43 51
 
44 52
 	/**
45 53
 	 * The name of the contextual object for the conversation resolver (see
46  
-	 * {@link Scope#resolveContextualObject(String)}).
  54
+	 * {@link org.springframework.beans.factory.config.Scope#resolveContextualObject(String)}).
47 55
 	 */
48 56
 	public static final String REFERENCE_CONVERSATION_RESOLVER = "conversationResolver";
49  
-}
  57
+
  58
+
  59
+	/** Holds the conversation manager reference, if statically injected. */
  60
+	private ConversationManager conversationManager;
  61
+
  62
+	/** Holds the conversation store reference, if statically injected. */
  63
+	private ConversationStore conversationStore;
  64
+
  65
+	/** Holds the conversation resolver reference, if statically injected. */
  66
+	private ConversationResolver conversationResolver;
  67
+
  68
+	/**
  69
+	 * This method is invoked to resolve the current conversation used where
  70
+	 * attributes having conversation scope are being resolved with or stored
  71
+	 * in.
  72
+	 * 
  73
+	 * @return the currently used conversation, or <code>null</code>, if no one
  74
+	 * currently available and <code>createIfNotExisting</code> is
  75
+	 * <code>false</code>
  76
+	 */
  77
+	protected Conversation getCurrentConversation(boolean createNewIfNotExisting) {
  78
+		ConversationResolver resolver = getConversationResolver();
  79
+		Assert.notNull(resolver, "No conversation resolver available within the conversation scope");
  80
+
  81
+		String conversationId = resolver.getCurrentConversationId();
  82
+		Conversation conversation;
  83
+		if (conversationId == null) {
  84
+			if (createNewIfNotExisting) {
  85
+				// start a new, temporary conversation using the default join
  86
+				// mode
  87
+				ConversationManager manager = getConversationManager();
  88
+				conversation = manager.beginConversation(true, JoinMode.getDefaultJoinMode());
  89
+			} else {
  90
+				return null;
  91
+			}
  92
+		} else {
  93
+			ConversationStore store = getConversationStore();
  94
+			Assert.notNull(store, "No conversation store available within the conversation scope");
  95
+			conversation = store.getConversation(conversationId);
  96
+			Assert.notNull(conversation, "The conversation with id <" + conversationId
  97
+					+ "> is not available within the store");
  98
+		}
  99
+
  100
+		return conversation;
  101
+	}
  102
+
  103
+	/**
  104
+	 * @see org.springframework.beans.factory.config.Scope#get(java.lang.String,
  105
+	 * org.springframework.beans.factory.ObjectFactory)
  106
+	 */
  107
+	public Object get(String name, ObjectFactory<?> objectFactory) {
  108
+		Conversation conversation = getCurrentConversation(true);
  109
+		Object attribute = conversation.getAttribute(name);
  110
+		if (attribute == null) {
  111
+			attribute = objectFactory.getObject();
  112
+			conversation.setAttribute(name, attribute);
  113
+		}
  114
+
  115
+		return attribute;
  116
+	}
  117
+
  118
+	/**
  119
+	 * @see org.springframework.beans.factory.config.Scope#getConversationId()
  120
+	 */
  121
+	public String getConversationId() {
  122
+		Conversation conversation = getCurrentConversation(false);
  123
+		if (conversation != null) {
  124
+			return conversation.getId();
  125
+		}
  126
+
  127
+		return null;
  128
+	}
  129
+
  130
+	/**
  131
+	 * @see org.springframework.beans.factory.config.Scope#registerDestructionCallback(java.lang.String,
  132
+	 * java.lang.Runnable)
  133
+	 */
  134
+	public void registerDestructionCallback(String name, Runnable callback) {
  135
+		Conversation conversation = getCurrentConversation(false);
  136
+		if (conversation != null) {
  137
+			conversation.registerDestructionCallback(name, callback);
  138
+		}
  139
+	}
  140
+
  141
+	/**
  142
+	 * @see org.springframework.beans.factory.config.Scope#remove(java.lang.String)
  143
+	 */
  144
+	public Object remove(String name) {
  145
+		Conversation conversation = getCurrentConversation(false);
  146
+		if (conversation != null) {
  147
+			return conversation.removeAttribute(name);
  148
+		}
  149
+
  150
+		return null;
  151
+	}
  152
+
  153
+	/**
  154
+	 * Supports the following objects:
  155
+	 * <ul>
  156
+	 * <li><code>"conversationManager"</code>, returns the {@link ConversationManager}</li>
  157
+	 * <li><code>"conversationStore"</code>, returns the {@link ConversationStore}</li>
  158
+	 * <li><code>"conversationResolver"</code>, returns the {@link ConversationResolver}</li>
  159
+	 * </ul>
  160
+	 *
  161
+	 * @see org.springframework.beans.factory.config.Scope#resolveContextualObject(java.lang.String)
  162
+	 */
  163
+	public Object resolveContextualObject(String key) {
  164
+		if (REFERENCE_CONVERSATION_MANAGER.equals(key)) {
  165
+			return getConversationManager();
  166
+		} else if (REFERENCE_CONVERSATION_STORE.equals(key)) {
  167
+			return getConversationStore();
  168
+		} else if (REFERENCE_CONVERSATION_RESOLVER.equals(key)) {
  169
+			return getConversationResolver();
  170
+		}
  171
+
  172
+		return null;
  173
+	}
  174
+
  175
+	/**
  176
+	 * @param conversationManager the conversation manager reference to be used
  177
+	 * by this scope
  178
+	 */
  179
+	public void setConversationManager(ConversationManager conversationManager) {
  180
+		this.conversationManager = conversationManager;
  181
+	}
  182
+
  183
+	/**
  184
+	 * @return the conversation manager reference
  185
+	 */
  186
+	public ConversationManager getConversationManager() {
  187
+		return conversationManager;
  188
+	}
  189
+
  190
+	/**
  191
+	 * @param conversationStore the reference of the conversation store to be
  192
+	 * injected and internally used to request registered conversation objects
  193
+	 */
  194
+	public void setConversationStore(ConversationStore conversationStore) {
  195
+		this.conversationStore = conversationStore;
  196
+	}
  197
+
  198
+	/**
  199
+	 * Returns the reference of the conversation store to be used. If the store
  200
+	 * is not within the same scope as the conversation scope, this method has
  201
+	 * to be injected.
  202
+	 * 
  203
+	 * @return the reference of the conversation store
  204
+	 */
  205
+	public ConversationStore getConversationStore() {
  206
+		return conversationStore;
  207
+	}
  208
+
  209
+	/**
  210
+	 * @param conversationResolver the reference of the conversation resolver
  211
+	 * used to determine the currently used conversation id
  212
+	 */
  213
+	public void setConversationResolver(ConversationResolver conversationResolver) {
  214
+		this.conversationResolver = conversationResolver;
  215
+	}
  216
+
  217
+	/**
  218
+	 * Returns the reference of the conversation resolver to be used. If the
  219
+	 * resolver is not within the same scope as the conversation scope, this
  220
+	 * method has to be injected.
  221
+	 *
  222
+	 * @return the reference of the conversation resolver
  223
+	 */
  224
+	public ConversationResolver getConversationResolver() {
  225
+		return conversationResolver;
  226
+	}
  227
+}
208  ...ringframework.context/src/main/java/org/springframework/conversation/scope/DefaultConversationScope.java
... ...
@@ -1,208 +0,0 @@
1  
-/*
2  
- * Copyright 2002-2008 the original author or authors.
3  
- * 
4  
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  
- * use this file except in compliance with the License. You may obtain a copy of
6  
- * the License at
7  
- * 
8  
- * http://www.apache.org/licenses/LICENSE-2.0
9  
- * 
10  
- * Unless required by applicable law or agreed to in writing, software
11  
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  
- * License for the specific language governing permissions and limitations under
14  
- * the License.
15  
- */
16  
-package org.springframework.conversation.scope;
17  
-
18  
-import org.springframework.beans.factory.ObjectFactory;
19  
-import org.springframework.conversation.Conversation;
20  
-import org.springframework.conversation.JoinMode;
21  
-import org.springframework.conversation.manager.ConversationManager;
22  
-import org.springframework.conversation.manager.ConversationResolver;
23  
-import org.springframework.conversation.manager.ConversationStore;
24  
-import org.springframework.util.Assert;
25  
-
26  
-/**
27  
- * The default implementation of the {@link ConversationScope} exposed as
28  
- * <code>"conversation"</code> scope. It needs the {@link ConversationStore} and
29  
- * the {@link ConversationResolver} to resolve and request the current
30  
- * conversation where attributes are resolved with and registered in.
31  
- * 
32  
- * @author Micha Kiener
33  
- * @since 3.1
34  
- */
35  
-public class DefaultConversationScope implements ConversationScope{
36  
-
37  
-	/** Holds the conversation manager reference, if statically injected. */
38  
-	private ConversationManager conversationManager;
39  
-
40  
-	/** Holds the conversation store reference, if statically injected. */
41  
-	private ConversationStore conversationStore;
42  
-
43  
-	/** Holds the conversation resolver reference, if statically injected. */
44  
-	private ConversationResolver conversationResolver;
45  
-
46  
-	/**
47  
-	 * This method is invoked to resolve the current conversation used where
48  
-	 * attributes having conversation scope are being resolved with or stored
49  
-	 * in.
50  
-	 * 
51  
-	 * @return the currently used conversation, or <code>null</code>, if no one
52  
-	 * currently available and <code>createIfNotExisting</code> is
53  
-	 * <code>false</code>
54  
-	 */
55  
-	protected Conversation getCurrentConversation(boolean createNewIfNotExisting) {
56  
-		ConversationResolver resolver = getConversationResolver();
57  
-		Assert.notNull(resolver, "No conversation resolver available within the conversation scope");
58  
-
59  
-		String conversationId = resolver.getCurrentConversationId();
60  
-		Conversation conversation;
61  
-		if (conversationId == null) {
62  
-			if (createNewIfNotExisting) {
63  
-				// start a new, temporary conversation using the default join
64  
-				// mode
65  
-				ConversationManager manager = getConversationManager();
66  
-				conversation = manager.beginConversation(true, JoinMode.getDefaultJoinMode());
67  
-			} else {
68  
-				return null;
69  
-			}
70  
-		} else {
71  
-			ConversationStore store = getConversationStore();
72  
-			Assert.notNull(store, "No conversation store available within the conversation scope");
73  
-			conversation = store.getConversation(conversationId);
74  
-			Assert.notNull(conversation, "The conversation with id <" + conversationId
75  
-					+ "> is not available within the store");
76  
-		}
77  
-
78  
-		return conversation;
79  
-	}
80  
-
81  
-	/**
82  
-	 * @see org.springframework.beans.factory.config.Scope#get(java.lang.String,
83  
-	 * org.springframework.beans.factory.ObjectFactory)
84  
-	 */
85  
-	public Object get(String name, ObjectFactory<?> objectFactory) {
86  
-		Conversation conversation = getCurrentConversation(true);
87  
-		Object attribute = conversation.getAttribute(name);
88  
-		if (attribute == null) {
89  
-			attribute = objectFactory.getObject();
90  
-			conversation.setAttribute(name, attribute);
91  
-		}
92  
-
93  
-		return attribute;
94  
-	}
95  
-
96  
-	/**
97  
-	 * @see org.springframework.beans.factory.config.Scope#getConversationId()
98  
-	 */
99  
-	public String getConversationId() {
100  
-		Conversation conversation = getCurrentConversation(false);
101  
-		if (conversation != null) {
102  
-			return conversation.getId();
103  
-		}
104  
-
105  
-		return null;
106  
-	}
107  
-
108  
-	/**
109  
-	 * @see org.springframework.beans.factory.config.Scope#registerDestructionCallback(java.lang.String,
110  
-	 * java.lang.Runnable)
111  
-	 */
112  
-	public void registerDestructionCallback(String name, Runnable callback) {
113  
-		Conversation conversation = getCurrentConversation(false);
114  
-		if (conversation != null) {
115  
-			conversation.registerDestructionCallback(name, callback);
116  
-		}
117  
-	}
118  
-
119  
-	/**
120  
-	 * @see org.springframework.beans.factory.config.Scope#remove(java.lang.String)
121  
-	 */
122  
-	public Object remove(String name) {
123  
-		Conversation conversation = getCurrentConversation(false);
124  
-		if (conversation != null) {
125  
-			return conversation.removeAttribute(name);
126  
-		}
127  
-
128  
-		return null;
129  
-	}
130  
-
131  
-	/**
132  
-	 * Supports the following objects:
133  
-	 * <ul>
134  
-	 * <li><code>"conversationManager"</code>, returns the
135  
-	 * {@link ConversationManager}</li>
136  
-	 * <li><code>"conversationStore"</code>, returns the
137  
-	 * {@link ConversationStore}</li>
138  
-	 * <li><code>"conversationResolver"</code>, returns the
139  
-	 * {@link ConversationResolver}</li>
140  
-	 * </ul>
141  
-	 * 
142  
-	 * @see org.springframework.beans.factory.config.Scope#resolveContextualObject(java.lang.String)
143  
-	 */
144  
-	public Object resolveContextualObject(String key) {
145  
-		if (ConversationScope.REFERENCE_CONVERSATION_MANAGER.equals(key)) {
146  
-			return getConversationManager();
147  
-		} else if (ConversationScope.REFERENCE_CONVERSATION_STORE.equals(key)) {
148  
-			return getConversationStore();
149  
-		} else if (ConversationScope.REFERENCE_CONVERSATION_RESOLVER.equals(key)) {
150  
-			return getConversationResolver();
151  
-		}
152  
-
153  
-		return null;
154  
-	}
155  
-
156  
-	/**
157  
-	 * @param conversationManager the conversation manager reference to be used
158  
-	 * by this scope
159  
-	 */
160  
-	public void setConversationManager(ConversationManager conversationManager) {
161  
-		this.conversationManager = conversationManager;
162  
-	}
163  
-
164  
-	/**
165  
-	 * @return the conversation manager reference
166  
-	 */
167  
-	public ConversationManager getConversationManager() {
168  
-		return conversationManager;
169  
-	}
170  
-
171  
-	/**
172  
-	 * @param conversationStore the reference of the conversation store to be
173  
-	 * injected and internally used to request registered conversation objects
174  
-	 */
175  
-	public void setConversationStore(ConversationStore conversationStore) {
176  
-		this.conversationStore = conversationStore;
177  
-	}
178  
-
179  
-	/**
180  
-	 * Returns the reference of the conversation store to be used. If the store
181  
-	 * is not within the same scope as the conversation scope, this method has
182  
-	 * to be injected.
183  
-	 * 
184  
-	 * @return the reference of the conversation store
185  
-	 */
186  
-	public ConversationStore getConversationStore() {
187  
-		return conversationStore;
188  
-	}
189  
-
190  
-	/**
191  
-	 * @param conversationResolver the reference of the conversation resolver
192  
-	 * used to determine the currently used conversation id
193  
-	 */
194  
-	public void setConversationResolver(ConversationResolver conversationResolver) {
195  
-		this.conversationResolver = conversationResolver;
196  
-	}
197  
-
198  
-	/**
199  
-	 * Returns the reference of the conversation resolver to be used. If the
200  
-	 * resolver is not within the same scope as the conversation scope, this
201  
-	 * method has to be injected.
202  
-	 * 
203  
-	 * @return the reference of the conversation resolver
204  
-	 */
205  
-	public ConversationResolver getConversationResolver() {
206  
-		return conversationResolver;
207  
-	}
208  
-}
2  org.springframework.context/src/test/java/org/springframework/conversation/conversationTestContext.xml
@@ -31,7 +31,7 @@
31 31
     
32 32
     <bean id="conversationResolver" class="org.springframework.conversation.manager.ThreadAttachedConversationResolver" />
33 33
     
34  
-    <bean id="conversationScope" class="org.springframework.conversation.scope.DefaultConversationScope" lazy-init="false">
  34
+    <bean id="conversationScope" class="org.springframework.conversation.scope.ConversationScope" lazy-init="false">
35 35
         <property name="conversationManager" ref="conversationManager"/>
36 36
         <property name="conversationStore" ref="conversationStore"/>
37 37
         <property name="conversationResolver" ref="conversationResolver"/>
8  org.springframework.web/src/main/java/org/springframework/web/conversation/WebAwareConversationScope.java
@@ -15,22 +15,22 @@
15 15
  */
16 16
 package org.springframework.web.conversation;
17 17
 
18  
-import org.springframework.conversation.scope.DefaultConversationScope;
  18
+import org.springframework.conversation.scope.ConversationScope;
19 19
 import org.springframework.web.context.request.RequestAttributes;
20 20
 import org.springframework.web.context.request.RequestContextHolder;
21 21
 
22 22
 /**
23 23
  * The extension of the default conversation scope (
24  
- * {@link DefaultConversationScope}) by supporting contextual web objects
  24
+ * {@link org.springframework.conversation.scope.ConversationScope}) by supporting contextual web objects
25 25
  * returned by overwriting {@link #resolveContextualObject(String)}.
26 26
  * 
27 27
  * @author Micha Kiener
28 28
  * @since 3.1
29 29
  */
30  
-public class WebAwareConversationScope extends DefaultConversationScope {
  30
+public class WebAwareConversationScope extends ConversationScope {
31 31
 
32 32
 	/**
33  
-	 * @see org.springframework.conversation.scope.DefaultConversationScope#resolveContextualObject(java.lang.String)
  33
+	 * @see org.springframework.conversation.scope.ConversationScope#resolveContextualObject(java.lang.String)
34 34
 	 */
35 35
 	@Override
36 36
 	public Object resolveContextualObject(String key) {

0 notes on commit 92ff07d

Please sign in to comment.
Something went wrong with that request. Please try again.