max-execution-snapshots = 0 support
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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.
|
||||
* <p>
|
||||
@@ -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 + "']";
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -25,5 +25,9 @@
|
||||
<webflow:flow-registry id="flowRegistry">
|
||||
<webflow:flow-location path="org/springframework/webflow/config/flow.xml" />
|
||||
</webflow:flow-registry>
|
||||
|
||||
<webflow:flow-executor id="flowExecutorSimpleRepo" flow-registry="flowRegistry">
|
||||
<webflow:flow-execution-repository max-execution-snapshots="0"/>
|
||||
</webflow:flow-executor>
|
||||
|
||||
</beans>
|
||||
Reference in New Issue
Block a user