This commit is contained in:
Keith Donald
2009-03-13 20:43:46 +00:00
parent 899ded4e21
commit 16002d174c
2 changed files with 18 additions and 14 deletions

View File

@@ -36,16 +36,12 @@ import org.springframework.webflow.engine.model.registry.FlowModelHolder;
*/
public class DefaultFlowModelHolder implements FlowModelHolder {
/**
* The flow model assembled by this assembler.
*/
private FlowModel flowModel;
/**
* The flow model builder.
*/
private FlowModelBuilder flowModelBuilder;
private boolean assembling;
/**
* Creates a new refreshable flow model holder that uses the configured assembler (GOF director) to drive flow
* assembly, on initial use and on any resource change or refresh.
@@ -57,6 +53,10 @@ public class DefaultFlowModelHolder implements FlowModelHolder {
}
public synchronized FlowModel getFlowModel() {
if (assembling) {
// must return early assembly result for when a flow calls itself recursively
return flowModelBuilder.getFlowModel();
}
if (flowModel == null) {
assembleFlowModel();
} else {
@@ -83,11 +83,16 @@ public class DefaultFlowModelHolder implements FlowModelHolder {
private void assembleFlowModel() throws FlowModelBuilderException {
try {
assembling = true;
flowModelBuilder.init();
flowModelBuilder.build();
flowModel = flowModelBuilder.getFlowModel();
} finally {
flowModelBuilder.dispose();
try {
flowModelBuilder.dispose();
} finally {
assembling = false;
}
}
}

View File

@@ -21,11 +21,10 @@ import org.springframework.webflow.engine.model.FlowModel;
/**
* Builder interface used to build a flow model. The process of building a flow model consists of the following steps:
* <ol>
* <li> Initialize this builder by calling {@link #init()}.
* <li> Call {@link #build()} to create the flow model.
* <li> Call {@link #getFlowModel()} to return the fully-built {@link FlowModel} model.
* <li> Dispose this builder, releasing any resources allocated during the building process by calling
* {@link #dispose()}.
* <li>Initialize this builder by calling {@link #init()}.
* <li>Call {@link #build()} to create the flow model.
* <li>Call {@link #getFlowModel()} to return the fully-built {@link FlowModel} model.
* <li>Dispose this builder, releasing any resources allocated during the building process by calling {@link #dispose()}.
* </ol>
* <p>
* Implementations should encapsulate flow construction logic, either for a specific kind of flow, for example, an
@@ -77,8 +76,8 @@ public interface FlowModelBuilder {
public Resource getFlowModelResource();
/**
* Returns true if the underlying flow model resource has changed since the last call to {@link #init()}.
* Always returns false if the flow model is not build from a resource.
* Returns true if the underlying flow model resource has changed since the last call to {@link #init()}. Always
* returns false if the flow model is not build from a resource.
* @return true if the resource backing the flow model has changed
*/
public boolean hasFlowModelResourceChanged();