From 653650234fbe11f1cca6dedc0e8a0610b265c2b7 Mon Sep 17 00:00:00 2001 From: Erwin Vervaet Date: Thu, 3 May 2007 08:01:31 +0000 Subject: [PATCH] Code review of SWF scope support for Spring. --- .../context/scope/AbstractWebFlowScope.java | 17 ++++++++++------- .../context/scope/ConversationScope.java | 3 ++- .../webflow/context/scope/FlashScope.java | 3 ++- .../webflow/context/scope/FlowScope.java | 3 ++- .../webflow/context/scope/ScopeRegistrar.java | 1 + .../webflow/context/scope/package.html | 6 ++++++ .../execution/FlowExecutionContextHolder.java | 2 +- 7 files changed, 24 insertions(+), 11 deletions(-) create mode 100644 spring-webflow/src/main/java/org/springframework/webflow/context/scope/package.html diff --git a/spring-webflow/src/main/java/org/springframework/webflow/context/scope/AbstractWebFlowScope.java b/spring-webflow/src/main/java/org/springframework/webflow/context/scope/AbstractWebFlowScope.java index 290eae65..93d69469 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/context/scope/AbstractWebFlowScope.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/context/scope/AbstractWebFlowScope.java @@ -34,10 +34,11 @@ import org.springframework.webflow.execution.RequestContext; *

Relies on a thread-bound @{link FlowExecutionContext} instance wich is located * through a @{link FlowExecutionContextHolder}. * - * @author Ben Hale - * @since 1.1 * @see FlowExecutionContext * @see FlowExecutionContextHolder + * + * @author Ben Hale + * @since 1.1 */ public abstract class AbstractWebFlowScope implements Scope { @@ -60,7 +61,8 @@ public abstract class AbstractWebFlowScope implements Scope { MutableAttributeMap scope; try { scope = getScope(); - } catch(IllegalStateException e) { + } + catch(IllegalStateException e) { throw new ScopedBeanException("Cannot retrieve scoped bean '" + name + "' before the scope has been populated"); } @@ -72,10 +74,10 @@ public abstract class AbstractWebFlowScope implements Scope { } scopedObject = objectFactory.getObject(); scope.put(name, scopedObject); - } else { + } + else { if(logger.isDebugEnabled()) { - logger.debug("Found existing scoped instance of '" + - name + "'"); + logger.debug("Found existing scoped instance of '" + name + "'"); } } return scopedObject; @@ -84,7 +86,8 @@ public abstract class AbstractWebFlowScope implements Scope { public Object remove(String name) { try { return getScope().remove(name); - } catch(IllegalStateException e) { + } + catch(IllegalStateException e) { throw new ScopedBeanException("Cannot remove scoped bean '" + name + "' before the scope has been populated"); } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/context/scope/ConversationScope.java b/spring-webflow/src/main/java/org/springframework/webflow/context/scope/ConversationScope.java index 15c34fa1..ad007de7 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/context/scope/ConversationScope.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/context/scope/ConversationScope.java @@ -22,9 +22,10 @@ import org.springframework.webflow.execution.FlowExecution; /** * Conversation-backed {@link Scope} implementation. * + * @see FlowExecution#getConversationScope() + * * @author Ben Hale * @since 1.1 - * @see FlowExecution#getConversationScope() */ public class ConversationScope extends AbstractWebFlowScope { diff --git a/spring-webflow/src/main/java/org/springframework/webflow/context/scope/FlashScope.java b/spring-webflow/src/main/java/org/springframework/webflow/context/scope/FlashScope.java index 4b8ea80f..0e5de611 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/context/scope/FlashScope.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/context/scope/FlashScope.java @@ -22,9 +22,10 @@ import org.springframework.webflow.execution.FlowSession; /** * Flash-backed {@link Scope} implementation. * + * @see FlowSession#getFlashMap() + * * @author Ben Hale * @since 1.1 - * @see FlowSession#getFlashMap() */ public class FlashScope extends AbstractWebFlowScope { diff --git a/spring-webflow/src/main/java/org/springframework/webflow/context/scope/FlowScope.java b/spring-webflow/src/main/java/org/springframework/webflow/context/scope/FlowScope.java index 1d6d8d43..435007be 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/context/scope/FlowScope.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/context/scope/FlowScope.java @@ -22,9 +22,10 @@ import org.springframework.webflow.execution.FlowSession; /** * Flow-backed {@link Scope} implementation. * + * @see FlowSession#getScope() + * * @author Ben Hale * @since 1.1 - * @see FlowSession#getScope() */ public class FlowScope extends AbstractWebFlowScope { diff --git a/spring-webflow/src/main/java/org/springframework/webflow/context/scope/ScopeRegistrar.java b/spring-webflow/src/main/java/org/springframework/webflow/context/scope/ScopeRegistrar.java index 9d9cdf8e..f593237f 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/context/scope/ScopeRegistrar.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/context/scope/ScopeRegistrar.java @@ -27,6 +27,7 @@ import org.springframework.webflow.execution.ScopeType; * * @author Ben Hale * @see Scope + * @since 1.1 */ public class ScopeRegistrar implements BeanFactoryPostProcessor, Ordered { diff --git a/spring-webflow/src/main/java/org/springframework/webflow/context/scope/package.html b/spring-webflow/src/main/java/org/springframework/webflow/context/scope/package.html new file mode 100644 index 00000000..06917e9c --- /dev/null +++ b/spring-webflow/src/main/java/org/springframework/webflow/context/scope/package.html @@ -0,0 +1,6 @@ + + +Support code to allow access to the Spring Web Flow scopes (conversation, flow, flash) +from a Spring ApplicationContext. + + diff --git a/spring-webflow/src/main/java/org/springframework/webflow/execution/FlowExecutionContextHolder.java b/spring-webflow/src/main/java/org/springframework/webflow/execution/FlowExecutionContextHolder.java index bef4aee0..cbe4c413 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/execution/FlowExecutionContextHolder.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/execution/FlowExecutionContextHolder.java @@ -53,7 +53,7 @@ public class FlowExecutionContextHolder { */ public static FlowExecutionContext getFlowExecutionContext() { Assert.state(flowExecutionContextHolder.get() != null, - "No request context is bound to this thread"); + "No flow execution context is bound to this thread"); return (FlowExecutionContext) flowExecutionContextHolder.get(); }