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

java.lang.Object
  extended by org.springframework.webflow.definition.registry.AbstractFlowDefinitionRegistryFactoryBean
      extended by org.springframework.webflow.engine.builder.AbstractFlowBuildingFlowRegistryFactoryBean
          extended by org.springframework.webflow.engine.builder.xml.XmlFlowRegistryFactoryBean
All Implemented Interfaces:
org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.FactoryBean, org.springframework.beans.factory.InitializingBean, org.springframework.context.ResourceLoaderAware

public class XmlFlowRegistryFactoryBean
extends AbstractFlowBuildingFlowRegistryFactoryBean

A factory bean that produces a populated flow registry using an XmlFlowRegistrar. This is the simplest implementation to use when using a Spring BeanFactory to deploy an explicit registry of XML-based Flow definitions for execution.

By default, a configured flow definition will be assigned a registry identifier equal to the filename of the underlying definition resource, minus the filename extension. For example, an XML-based flow definition defined in the file flow1.xml will be identified as flow1 in the registry created by this factory bean.

This class is also BeanFactoryAware and when used with Spring will automatically create a configured DefaultFlowServiceLocator for loading Flow artifacts like Actions from the Spring bean factory during the Flow registration process.

This class is also ResourceLoaderAware; when an instance is created by a Spring BeanFactory the factory will automatically configure the XmlFlowRegistrar with a context-relative resource loader for accessing other resources during Flow assembly. Usage example:

     <bean id="flowRegistry" class="org.springframework.webflow.engine.builder.registry.XmlFlowRegistryFactoryBean">
         <property name="flowLocations" value="/WEB-INF/flows/*-flow.xml"/> 
     </bean>
 

Author:
Keith Donald

Constructor Summary
XmlFlowRegistryFactoryBean()
           
 
Method Summary
protected  void doPopulate(FlowDefinitionRegistry registry)
          Template method subclasses must override to perform registry population.
 XmlFlowRegistrar getXmlFlowRegistrar()
          Returns the configured externalized XML flow registrar.
protected  void init(FlowServiceLocator flowServiceLocator)
          Called after properties have been set on the service locator, but before registry population.
 void setDocumentLoader(DocumentLoader documentLoader)
          Sets the loader to load XML-based flow definition documents during flow definition assembly.
 void setFlowAttributes(java.util.Map flowAttributes)
          Sets flow attributes from an externalized java.util.Map.
 void setFlowDefinitions(java.util.Properties flowDefinitions)
          Convenience method for setting externalized flow definitions from a java.util.Properties map.
 void setFlowLocations(org.springframework.core.io.Resource[] locations)
          Sets the locations (resource file paths) pointing to XML-based flow definitions.
 void setXmlFlowRegistrar(XmlFlowRegistrar flowRegistrar)
          Set the configured externalized XML flow registrar.
 
Methods inherited from class org.springframework.webflow.engine.builder.AbstractFlowBuildingFlowRegistryFactoryBean
createFlowServiceLocator, getBeanFactory, getBeanInvokingActionFactory, getConversionService, getExpressionParser, getFlowArtifactFactory, getFlowServiceLocator, getResourceLoader, init, setBeanFactory, setBeanInvokingActionFactory, setConversionService, setExpressionParser, setFlowArtifactFactory, setResourceLoader
 
Methods inherited from class org.springframework.webflow.definition.registry.AbstractFlowDefinitionRegistryFactoryBean
afterPropertiesSet, createFlowDefinitionRegistry, getObject, getObjectType, getRegistry, isSingleton, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlFlowRegistryFactoryBean

public XmlFlowRegistryFactoryBean()
Method Detail

getXmlFlowRegistrar

public XmlFlowRegistrar getXmlFlowRegistrar()
Returns the configured externalized XML flow registrar.


setXmlFlowRegistrar

public void setXmlFlowRegistrar(XmlFlowRegistrar flowRegistrar)
Set the configured externalized XML flow registrar.

Since:
1.0.1

setFlowLocations

public void setFlowLocations(org.springframework.core.io.Resource[] locations)
Sets the locations (resource file paths) pointing to XML-based flow definitions.

When configuring as a Spring bean definition, ANT-style resource patterns/wildcards are also supported, taking advantage of Spring's built in ResourceArrayPropertyEditor machinery.

For example:

     <bean id="flowRegistry" class="org.springframework.webflow.engine.builder.xml.XmlFlowRegistryFactoryBean">
         <property name="flowLocations" value="/WEB-INF/flows/*-flow.xml"/> 
     </bean>
 
Another example:
    <bean id="flowRegistry" class="org.springframework.webflow.engine.builder.xml.XmlFlowRegistryFactoryBean">
          <property name="flowLocations" value="classpath*:/example/flows/*-flow.xml"/> 
    </bean>
 
Flows registered from this set will be automatically assigned an id based on the filename of the matched XML resource.

Parameters:
locations - the resource locations

setFlowDefinitions

public void setFlowDefinitions(java.util.Properties flowDefinitions)
Convenience method for setting externalized flow definitions from a java.util.Properties map. Allows for more control over the definition, including which flowId is assigned.

Each property key is the flowId and each property value is the string encoded location of the externalized flow definition resource.

Here is the exact format:

 flowId = resource
 
For example:
     <bean id="flowRegistry" class="org.springframework.webflow.engine.builder.xml.XmlFlowRegistryFactoryBean">
         <property name="flowDefinitions">
             <value>
                 searchFlow=/WEB-INF/flows/search-flow.xml
                 detailFlow=/WEB-INF/flows/detail-flow.xml
             </value>
         </property>
     </bean>
 

Parameters:
flowDefinitions - the flow definitions, defined within a properties map

setFlowAttributes

public void setFlowAttributes(java.util.Map flowAttributes)
Sets flow attributes from an externalized java.util.Map. The keys in the map are String flow ids. The corresponding values should be java.util.Map maps containing flow attributes to be assigned to the flow. A flow with an id not contained in the provided map will get not externally defined flow attributes assigned.

Can be used in conjunction with both setFlowLocations(Resource[]) and setFlowDefinitions(Properties).

Parameters:
flowAttributes - the flow attributes, keyed by flow id
Since:
1.0.1

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 flow definition documents are loaded. Optional.

Parameters:
documentLoader - the document loader

init

protected void init(FlowServiceLocator flowServiceLocator)
Description copied from class: AbstractFlowBuildingFlowRegistryFactoryBean
Called after properties have been set on the service locator, but before registry population. Subclasses may override to perform custom initialization of the flow service locator.

Overrides:
init in class AbstractFlowBuildingFlowRegistryFactoryBean
Parameters:
flowServiceLocator - the flow service locator to use to locate externally managed services needed during flow building and assembly, typically used by a FlowDefinitionRegistrar

doPopulate

protected void doPopulate(FlowDefinitionRegistry registry)
Description copied from class: AbstractFlowDefinitionRegistryFactoryBean
Template method subclasses must override to perform registry population.

Specified by:
doPopulate in class AbstractFlowBuildingFlowRegistryFactoryBean
Parameters:
registry - the flow definition registry to populate


Copyright © 2004-2007. All Rights Reserved.