diff --git a/spring-webflow/src/main/java/org/springframework/webflow/config/FlowExecutorFactoryBean.java b/spring-webflow/src/main/java/org/springframework/webflow/config/FlowExecutorFactoryBean.java index 9379e778..0080b53f 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/config/FlowExecutorFactoryBean.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/config/FlowExecutorFactoryBean.java @@ -41,6 +41,7 @@ import org.springframework.webflow.execution.repository.FlowExecutionRepository; import org.springframework.webflow.execution.repository.impl.DefaultFlowExecutionRepository; import org.springframework.webflow.execution.repository.snapshot.FlowExecutionSnapshotFactory; import org.springframework.webflow.execution.repository.snapshot.SerializedFlowExecutionSnapshotFactory; +import org.springframework.webflow.execution.repository.snapshot.SimpleFlowExecutionSnapshotFactory; import org.springframework.webflow.executor.FlowExecutor; import org.springframework.webflow.executor.FlowExecutorImpl; import org.springframework.webflow.mvc.builder.MvcEnvironment; @@ -188,7 +189,12 @@ class FlowExecutorFactoryBean implements FactoryBean, ApplicationContextAware, I } private FlowExecutionSnapshotFactory createFlowExecutionSnapshotFactory(FlowExecutionFactory executionFactory) { - return new SerializedFlowExecutionSnapshotFactory(executionFactory, flowDefinitionLocator); + if (maxFlowExecutionSnapshots != null && maxFlowExecutionSnapshots.intValue() == 0) { + maxFlowExecutionSnapshots = new Integer(1); + return new SimpleFlowExecutionSnapshotFactory(executionFactory, flowDefinitionLocator); + } else { + return new SerializedFlowExecutionSnapshotFactory(executionFactory, flowDefinitionLocator); + } } private FlowExecutionImplFactory createFlowExecutionFactory(AttributeMap executionAttributes) { diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/impl/FlowSessionImpl.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/impl/FlowSessionImpl.java index 54ea8c23..c30fd1e0 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/impl/FlowSessionImpl.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/impl/FlowSessionImpl.java @@ -49,11 +49,6 @@ class FlowSessionImpl implements FlowSession, Externalizable { */ private transient Flow flow; - /** - * Set so the transient {@link #flow} field can be restored by the {@link FlowExecutionImplFactory}. - */ - private String flowId; - /** * The current state of this flow session. *
@@ -61,11 +56,6 @@ class FlowSessionImpl implements FlowSession, Externalizable {
*/
private transient State state;
- /**
- * Set so the transient {@link #state} field can be restored by the {@link FlowExecutionImplFactory}.
- */
- private String stateId;
-
/**
* The session data model ("flow scope").
*/
@@ -76,6 +66,16 @@ class FlowSessionImpl implements FlowSession, Externalizable {
*/
private FlowSessionImpl parent;
+ /**
+ * Set so the transient {@link #flow} field can be restored by the {@link FlowExecutionImplFactory}.
+ */
+ private String flowId;
+
+ /**
+ * Set so the transient {@link #state} field can be restored by the {@link FlowExecutionImplFactory}.
+ */
+ private String stateId;
+
/**
* Default constructor required for externalizable serialization. Should NOT be called programmatically.
*/
@@ -150,7 +150,7 @@ class FlowSessionImpl implements FlowSession, Externalizable {
public void writeExternal(ObjectOutput out) throws IOException {
out.writeObject(flow.getId());
- out.writeObject(state.getId());
+ out.writeObject(state != null ? state.getId() : null);
out.writeObject(scope);
out.writeObject(parent);
}
@@ -190,7 +190,11 @@ class FlowSessionImpl implements FlowSession, Externalizable {
* Returns the de-serialized id indicating the flow id of this session.
*/
String getFlowId() {
- return flowId;
+ if (flow == null) {
+ return flowId;
+ } else {
+ return flow.getId();
+ }
}
/**
@@ -205,7 +209,11 @@ class FlowSessionImpl implements FlowSession, Externalizable {
* Returns the de-serialized id indicating the current state of this session.
*/
String getStateId() {
- return stateId;
+ if (state == null) {
+ return stateId;
+ } else {
+ return state.getId();
+ }
}
/**
@@ -234,8 +242,8 @@ class FlowSessionImpl implements FlowSession, Externalizable {
public String toString() {
if (flow != null) {
- return new ToStringCreator(this).append("flow", flow.getId()).append("state",
- state != null ? state.getId() : null).append("scope", scope).toString();
+ return new ToStringCreator(this).append("flow", getFlowId()).append("state", getStateId()).append("scope",
+ scope).toString();
} else {
return "[Unhydrated session '" + flowId + "' in state '" + stateId + "']";
}
diff --git a/spring-webflow/src/test/java/org/springframework/webflow/config/FlowExecutorBeanDefinitionParserTests.java b/spring-webflow/src/test/java/org/springframework/webflow/config/FlowExecutorBeanDefinitionParserTests.java
index 8a0ec39e..972a0f9d 100644
--- a/spring-webflow/src/test/java/org/springframework/webflow/config/FlowExecutorBeanDefinitionParserTests.java
+++ b/spring-webflow/src/test/java/org/springframework/webflow/config/FlowExecutorBeanDefinitionParserTests.java
@@ -19,6 +19,8 @@ public class FlowExecutorBeanDefinitionParserTests extends TestCase {
public void testConfigOk() {
FlowExecutor executor = (FlowExecutor) context.getBean("flowExecutor", FlowExecutor.class);
executor.launchExecution("flow", null, new MockExternalContext());
+ FlowExecutor executor2 = (FlowExecutor) context.getBean("flowExecutorSimpleRepo", FlowExecutor.class);
+ executor2.launchExecution("flow", null, new MockExternalContext());
}
public static class ConfigurationListener extends FlowExecutionListenerAdapter {
diff --git a/spring-webflow/src/test/java/org/springframework/webflow/config/flow-executor.xml b/spring-webflow/src/test/java/org/springframework/webflow/config/flow-executor.xml
index 01fbba17..3e3dfc8c 100644
--- a/spring-webflow/src/test/java/org/springframework/webflow/config/flow-executor.xml
+++ b/spring-webflow/src/test/java/org/springframework/webflow/config/flow-executor.xml
@@ -25,5 +25,9 @@