1 16 package org.springframework.webflow.engine.builder.xml; 17 18 import org.springframework.core.io.Resource; 19 import org.springframework.util.Assert; 20 import org.springframework.webflow.definition.registry.ExternalizedFlowDefinitionRegistrar; 21 import org.springframework.webflow.definition.registry.FlowDefinitionHolder; 22 import org.springframework.webflow.definition.registry.FlowDefinitionResource; 23 import org.springframework.webflow.engine.builder.FlowAssembler; 24 import org.springframework.webflow.engine.builder.FlowBuilder; 25 import org.springframework.webflow.engine.builder.FlowServiceLocator; 26 import org.springframework.webflow.engine.builder.RefreshableFlowDefinitionHolder; 27 28 56 public class XmlFlowRegistrar extends ExternalizedFlowDefinitionRegistrar { 57 58 61 private static final String XML_SUFFIX = ".xml"; 62 63 66 private FlowServiceLocator flowServiceLocator; 67 68 71 private DocumentLoader documentLoader; 72 73 77 protected XmlFlowRegistrar() { 78 } 79 80 85 public XmlFlowRegistrar(FlowServiceLocator flowServiceLocator) { 86 setFlowServiceLocator(flowServiceLocator); 87 } 88 89 93 protected void setFlowServiceLocator(FlowServiceLocator flowServiceLocator) { 94 Assert.notNull(flowServiceLocator, "The flow service locator is required"); 95 this.flowServiceLocator = flowServiceLocator; 96 } 97 98 101 protected FlowServiceLocator getFlowServiceLocator() { 102 return flowServiceLocator; 103 } 104 105 111 public void setDocumentLoader(DocumentLoader documentLoader) { 112 this.documentLoader = documentLoader; 113 } 114 115 118 public DocumentLoader getDocumentLoader() { 119 return documentLoader; 120 } 121 122 protected boolean isFlowDefinitionResource(Resource resource) { 123 return resource.getFilename().endsWith(XML_SUFFIX); 124 } 125 126 protected FlowDefinitionHolder createFlowDefinitionHolder(FlowDefinitionResource resource) { 127 FlowBuilder builder = createFlowBuilder(resource.getLocation()); 128 FlowAssembler assembler = new FlowAssembler(resource.getId(), resource.getAttributes(), builder); 129 return new RefreshableFlowDefinitionHolder(assembler); 130 } 131 132 134 140 protected FlowBuilder createFlowBuilder(Resource location) { 141 XmlFlowBuilder builder = new XmlFlowBuilder(location, getFlowServiceLocator()); 142 if (documentLoader != null) { 143 builder.setDocumentLoader(documentLoader); 144 } 145 return builder; 146 } 147 } | Popular Tags |