1 16 package org.springframework.webflow.engine.builder; 17 18 import org.springframework.binding.convert.ConversionException; 19 import org.springframework.binding.convert.ConversionExecutor; 20 import org.springframework.util.Assert; 21 import org.springframework.webflow.core.collection.AttributeMap; 22 import org.springframework.webflow.engine.Flow; 23 24 39 public abstract class BaseFlowBuilder implements FlowBuilder { 40 41 44 private Flow flow; 45 46 50 private FlowServiceLocator flowServiceLocator; 51 52 56 protected BaseFlowBuilder() { 57 setFlowServiceLocator(new BaseFlowServiceLocator()); 58 } 59 60 64 protected BaseFlowBuilder(FlowServiceLocator flowServiceLocator) { 65 setFlowServiceLocator(flowServiceLocator); 66 } 67 68 71 public FlowServiceLocator getFlowServiceLocator() { 72 return flowServiceLocator; 73 } 74 75 78 public void setFlowServiceLocator(FlowServiceLocator flowServiceLocator) { 79 Assert.notNull(flowServiceLocator, "The flow service locator is required"); 80 this.flowServiceLocator = flowServiceLocator; 81 } 82 83 88 protected void setFlow(Flow flow) { 89 this.flow = flow; 90 } 91 92 public abstract void init(String flowId, AttributeMap attributes) throws FlowBuilderException; 93 94 public void buildVariables() throws FlowBuilderException { 95 } 96 97 public void buildInputMapper() throws FlowBuilderException { 98 } 99 100 public void buildStartActions() throws FlowBuilderException { 101 } 102 103 public void buildInlineFlows() throws FlowBuilderException { 104 } 105 106 public abstract void buildStates() throws FlowBuilderException; 107 108 public void buildGlobalTransitions() throws FlowBuilderException { 109 } 110 111 public void buildEndActions() throws FlowBuilderException { 112 } 113 114 public void buildOutputMapper() throws FlowBuilderException { 115 } 116 117 public void buildExceptionHandlers() throws FlowBuilderException { 118 } 119 120 123 public Flow getFlow() { 124 return flow; 125 } 126 127 public void dispose() { 128 setFlow(null); 129 } 130 131 133 140 protected ConversionExecutor fromStringTo(String targetAlias) { 141 return getFlowServiceLocator().getConversionService().getConversionExecutorByTargetAlias(String .class, targetAlias); 142 } 143 144 151 protected ConversionExecutor fromStringTo(Class targetType) throws ConversionException { 152 return getFlowServiceLocator().getConversionService().getConversionExecutor(String .class, targetType); 153 } 154 } | Popular Tags |