Code review of SWF scope support for Spring.

This commit is contained in:
Erwin Vervaet
2007-05-03 08:01:31 +00:00
parent 10588f2bb7
commit 653650234f
7 changed files with 24 additions and 11 deletions

View File

@@ -34,10 +34,11 @@ import org.springframework.webflow.execution.RequestContext;
* <p>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");
}

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -27,6 +27,7 @@ import org.springframework.webflow.execution.ScopeType;
*
* @author Ben Hale
* @see Scope
* @since 1.1
*/
public class ScopeRegistrar implements BeanFactoryPostProcessor, Ordered {

View File

@@ -0,0 +1,6 @@
<html>
<body>
Support code to allow access to the Spring Web Flow scopes (conversation, flow, flash)
from a Spring ApplicationContext.
</body>
</html>

View File

@@ -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();
}