1 16 package org.springframework.webflow.engine.builder; 17 18 import org.springframework.util.Assert; 19 import org.springframework.webflow.core.collection.AttributeMap; 20 import org.springframework.webflow.core.collection.CollectionUtils; 21 import org.springframework.webflow.engine.Flow; 22 23 41 public class FlowAssembler { 42 43 46 private String flowId; 47 48 51 private AttributeMap flowAttributes; 52 53 57 private FlowBuilder flowBuilder; 58 59 65 public FlowAssembler(String flowId, FlowBuilder flowBuilder) { 66 this(flowId, null, flowBuilder); 67 } 68 69 77 public FlowAssembler(String flowId, AttributeMap flowAttributes, FlowBuilder flowBuilder) { 78 Assert.hasText(flowId, "The flow id is required"); 79 Assert.notNull(flowBuilder, "The flow builder is required"); 80 this.flowId = flowId; 81 this.flowAttributes = (flowAttributes != null ? flowAttributes : CollectionUtils.EMPTY_ATTRIBUTE_MAP); 82 this.flowBuilder = flowBuilder; 83 } 84 85 88 public String getFlowId() { 89 return flowId; 90 } 91 92 96 public AttributeMap getFlowAttributes() { 97 return flowAttributes; 98 } 99 100 104 public FlowBuilder getFlowBuilder() { 105 return flowBuilder; 106 } 107 108 120 public Flow assembleFlow() throws FlowBuilderException { 121 try { 122 flowBuilder.init(flowId, flowAttributes); 123 directAssembly(); 124 return flowBuilder.getFlow(); 125 } 126 finally { 127 flowBuilder.dispose(); 128 } 129 } 130 131 136 protected void directAssembly() throws FlowBuilderException { 137 flowBuilder.buildVariables(); 138 flowBuilder.buildInputMapper(); 139 flowBuilder.buildStartActions(); 140 flowBuilder.buildInlineFlows(); 141 flowBuilder.buildStates(); 142 flowBuilder.buildGlobalTransitions(); 143 flowBuilder.buildEndActions(); 144 flowBuilder.buildOutputMapper(); 145 flowBuilder.buildExceptionHandlers(); 146 } 147 } | Popular Tags |