From 16002d174cdd3f6b4fc5b791e17cfdbe04771327 Mon Sep 17 00:00:00 2001 From: Keith Donald Date: Fri, 13 Mar 2009 20:43:46 +0000 Subject: [PATCH] swf-1057 --- .../model/builder/DefaultFlowModelHolder.java | 19 ++++++++++++------- .../model/builder/FlowModelBuilder.java | 13 ++++++------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/builder/DefaultFlowModelHolder.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/builder/DefaultFlowModelHolder.java index f03480ba..d776dac3 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/builder/DefaultFlowModelHolder.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/builder/DefaultFlowModelHolder.java @@ -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; + } } } diff --git a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/builder/FlowModelBuilder.java b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/builder/FlowModelBuilder.java index 5d0a3e28..11dafda9 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/engine/model/builder/FlowModelBuilder.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/engine/model/builder/FlowModelBuilder.java @@ -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: *
    - *
  1. Initialize this builder by calling {@link #init()}. - *
  2. Call {@link #build()} to create the flow model. - *
  3. Call {@link #getFlowModel()} to return the fully-built {@link FlowModel} model. - *
  4. Dispose this builder, releasing any resources allocated during the building process by calling - * {@link #dispose()}. + *
  5. Initialize this builder by calling {@link #init()}. + *
  6. Call {@link #build()} to create the flow model. + *
  7. Call {@link #getFlowModel()} to return the fully-built {@link FlowModel} model. + *
  8. Dispose this builder, releasing any resources allocated during the building process by calling {@link #dispose()}. *
*

* 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();