org.springframework.webflow.engine.builder.xml
Class XmlFlowRegistrar

java.lang.Object
  extended by org.springframework.webflow.definition.registry.ExternalizedFlowDefinitionRegistrar
      extended by org.springframework.webflow.engine.builder.xml.XmlFlowRegistrar
All Implemented Interfaces:
FlowDefinitionRegistrar

public class XmlFlowRegistrar
extends ExternalizedFlowDefinitionRegistrar

A flow definition registrar that populates a flow definition registry with flow definitions defined in externalized XML resources. Typically used in conjunction with a XmlFlowRegistryFactoryBean but may also be used standalone in programmatic fashion.

By default, a flow definition registered by this registrar will be assigned a registry identifier equal to the filename of the underlying definition resource, minus the filename extension. For example, a XML-based flow definition defined in the file "flow1.xml" will be identified as "flow1" when registered in a registry.

Programmatic usage example:

     BeanFactory beanFactory = ...
     FlowDefinitionRegistry registry = new FlowDefinitionRegistryImpl();
     FlowServiceLocator flowServiceLocator =
         new DefaultFlowServiceLocator(registry, beanFactory);
     XmlFlowRegistrar registrar = new XmlFlowRegistrar(flowServiceLocator);
     File parent = new File("src/webapp/WEB-INF");
     registrar.addLocation(new FileSystemResource(new File(parent, "flow1.xml"));
     registrar.addLocation(new FileSystemResource(new File(parent, "flow2.xml"));
     registrar.registerFlowDefinitions(registry);
 

Author:
Keith Donald

Constructor Summary
protected XmlFlowRegistrar()
          Creates a new XML flow registrar.
  XmlFlowRegistrar(FlowServiceLocator flowServiceLocator)
          Creates a new XML flow registrar.
 
Method Summary
protected  FlowBuilder createFlowBuilder(org.springframework.core.io.Resource location)
          Factory method that creates and fully initializes the XML-based flow definition builder.
protected  FlowDefinitionHolder createFlowDefinitionHolder(FlowDefinitionResource resource)
          Template factory method subclasses must override to return the holder for the flow definition to be registered loaded from the specified resource.
 DocumentLoader getDocumentLoader()
          Returns the loader of XML-based flow definition documents.
protected  FlowServiceLocator getFlowServiceLocator()
          Returns the flow service locator.
protected  boolean isFlowDefinitionResource(org.springframework.core.io.Resource resource)
          Template method that calculates if the given file resource is actually a flow definition resource.
 void setDocumentLoader(DocumentLoader documentLoader)
          Sets the loader to load XML-based flow definition documents during flow definition assembly.
protected  void setFlowServiceLocator(FlowServiceLocator flowServiceLocator)
          Sets the flow service locator.
 
Methods inherited from class org.springframework.webflow.definition.registry.ExternalizedFlowDefinitionRegistrar
addLocation, addLocations, addResource, addResources, createFlowDefinitionResource, register, registerFlowDefinitions, setLocations, setResources, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XmlFlowRegistrar

protected XmlFlowRegistrar()
Creates a new XML flow registrar. Protected constructor - if used, make sure the required flowServiceLocator reference is set.


XmlFlowRegistrar

public XmlFlowRegistrar(FlowServiceLocator flowServiceLocator)
Creates a new XML flow registrar.

Parameters:
flowServiceLocator - the locator needed to support flow definition assembly
Method Detail

setFlowServiceLocator

protected void setFlowServiceLocator(FlowServiceLocator flowServiceLocator)
Sets the flow service locator.

Parameters:
flowServiceLocator - the flow service locator (may not be null)

getFlowServiceLocator

protected FlowServiceLocator getFlowServiceLocator()
Returns the flow service locator.


setDocumentLoader

public void setDocumentLoader(DocumentLoader documentLoader)
Sets the loader to load XML-based flow definition documents during flow definition assembly. Allows for customization over how documents are loaded. Optional.

Parameters:
documentLoader - the document loader

getDocumentLoader

public DocumentLoader getDocumentLoader()
Returns the loader of XML-based flow definition documents.


isFlowDefinitionResource

protected boolean isFlowDefinitionResource(org.springframework.core.io.Resource resource)
Description copied from class: ExternalizedFlowDefinitionRegistrar
Template method that calculates if the given file resource is actually a flow definition resource. Resources that aren't flow definitions will be ignored. Subclasses may override; this implementation simply returns true.

Overrides:
isFlowDefinitionResource in class ExternalizedFlowDefinitionRegistrar
Parameters:
resource - the underlying resource
Returns:
true if yes, false otherwise

createFlowDefinitionHolder

protected FlowDefinitionHolder createFlowDefinitionHolder(FlowDefinitionResource resource)
Description copied from class: ExternalizedFlowDefinitionRegistrar
Template factory method subclasses must override to return the holder for the flow definition to be registered loaded from the specified resource.

Specified by:
createFlowDefinitionHolder in class ExternalizedFlowDefinitionRegistrar
Parameters:
resource - the externalized resource
Returns:
the flow definition holder

createFlowBuilder

protected FlowBuilder createFlowBuilder(org.springframework.core.io.Resource location)
Factory method that creates and fully initializes the XML-based flow definition builder.

Parameters:
location - the xml-based resource
Returns:
the builder to build the flow definition from the resource.


Copyright © 2004-2007. All Rights Reserved.