277 lines
12 KiB
XML
277 lines
12 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<chapter id="system-setup">
|
|
<title>System Setup</title>
|
|
<sect1 id="system-setup-introduction">
|
|
<title>Introduction</title>
|
|
<para>
|
|
This chapter shows you how to setup the Web Flow system for use in any web environment.
|
|
</para>
|
|
</sect1>
|
|
<sect1 id="system-config-schema">
|
|
<title>webflow-config.xsd</title>
|
|
<para>
|
|
Web Flow provides a Spring schema that allows you to configure the system.
|
|
To use this schema, include it in one of your infrastructure-layer beans files:
|
|
</para>
|
|
<programlisting language="xml"><![CDATA[
|
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
xmlns:webflow="http://www.springframework.org/schema/webflow-config"
|
|
xsi:schemaLocation="
|
|
http://www.springframework.org/schema/beans
|
|
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
|
|
http://www.springframework.org/schema/webflow-config
|
|
http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd">
|
|
|
|
<!-- Setup Web Flow here -->
|
|
|
|
</beans>]]>
|
|
</programlisting>
|
|
</sect1>
|
|
<sect1 id="system-config-basic">
|
|
<title>Basic system configuration</title>
|
|
<para>
|
|
The next section shows the minimal configuration required to set up the Web Flow system in your application.
|
|
</para>
|
|
<sect2 id="basic-setup-flow-registry">
|
|
<title>FlowRegistry</title>
|
|
<para>
|
|
Register your flows in a <code>FlowRegistry</code>:
|
|
</para>
|
|
<programlisting language="xml"><![CDATA[
|
|
<webflow:flow-registry id="flowRegistry">
|
|
<webflow:flow-location path="/WEB-INF/flows/booking/booking.xml" />
|
|
</webflow:flow-registry>]]>
|
|
</programlisting>
|
|
</sect2>
|
|
<sect2 id="basic-setup-flow-executor">
|
|
<title>FlowExecutor</title>
|
|
<para>
|
|
Deploy a FlowExecutor, the central service for executing flows:
|
|
</para>
|
|
<programlisting language="xml"><![CDATA[
|
|
<webflow:flow-executor id="flowExecutor" />]]>
|
|
</programlisting>
|
|
</sect2>
|
|
<para>
|
|
See the Spring MVC and Spring Faces sections of this guide on how to integrate the Web Flow system with the MVC and JSF environment, respectively.
|
|
</para>
|
|
</sect1>
|
|
<sect1 id="flow-registry">
|
|
<title>flow-registry options</title>
|
|
<para>
|
|
This section explores flow-registry configuration options.
|
|
</para>
|
|
<sect2 id="flow-registry-location">
|
|
<title>Specifying flow locations</title>
|
|
<para>
|
|
Use the <code>location</code> element to specify paths to flow definitions to register.
|
|
By default, flows will be assigned registry identifiers equal to their filenames minus the file extension, unless a registry bath path is defined.
|
|
</para>
|
|
<programlisting language="xml"><![CDATA[
|
|
<webflow:flow-location path="/WEB-INF/flows/booking/booking.xml" />]]>
|
|
</programlisting>
|
|
</sect2>
|
|
<sect2 id="flow-registry-location-id">
|
|
<title>Assigning custom flow identifiers</title>
|
|
<para>
|
|
Specify an id to assign a custom registry identifier to a flow:
|
|
</para>
|
|
<programlisting language="xml"><![CDATA[
|
|
<webflow:flow-location path="/WEB-INF/flows/booking/booking.xml" id="bookHotel" />]]>
|
|
</programlisting>
|
|
</sect2>
|
|
<sect2 id="flow-registry-location-attributes">
|
|
<title>Assigning flow meta-attributes</title>
|
|
<para>
|
|
Use the <code>flow-definition-attributes</code> element to assign custom meta-attributes to a registered flow:
|
|
</para>
|
|
<programlisting language="xml"><![CDATA[
|
|
<webflow:flow-location path="/WEB-INF/flows/booking/booking.xml">
|
|
<flow-definition-attributes>
|
|
<attribute name="caption" value="Books a hotel" />
|
|
</flow-definition-attributes>
|
|
</webflow:flow-location>]]>
|
|
</programlisting>
|
|
</sect2>
|
|
<sect2 id="flow-registry-patterns">
|
|
<title>Registering flows using a location pattern</title>
|
|
<para>
|
|
Use the <code>flow-location-patterns</code> element to register flows that match a specific resource location pattern:
|
|
</para>
|
|
<programlisting language="xml"><![CDATA[
|
|
<webflow:flow-location-pattern value="/WEB-INF/flows/**/*-flow.xml" />]]>
|
|
</programlisting>
|
|
</sect2>
|
|
<sect2 id="flow-registry-base-path">
|
|
<title>Flow location base path</title>
|
|
<para>
|
|
Use the <code>base-path</code> attribute to define a base location for all flows in the application.
|
|
All flow locations are then relative to the base path.
|
|
The base path can be a resource path such as '/WEB-INF' or a location on the classpath like 'classpath:org/springframework/webflow/samples'.
|
|
</para>
|
|
<programlisting language="xml"><![CDATA[
|
|
<webflow:flow-registry id="flowRegistry" base-path="/WEB-INF">
|
|
<webflow:flow-location path="/hotels/booking/booking.xml" />
|
|
</webflow:flow-registry>]]>
|
|
</programlisting>
|
|
<para>
|
|
With a base path defined, the algorithm that assigns flow identifiers changes slightly.
|
|
Flows will now be assigned registry identifiers equal to the the path segment between their base path and file name.
|
|
For example, if a flow definition is located at '/WEB-INF/hotels/booking/booking-flow.xml' and the base path is '/WEB-INF' the remaining path to this flow is 'hotels/booking' which becomes the flow id.
|
|
</para>
|
|
<tip>
|
|
<title>Directory per flow definition</title>
|
|
<para>
|
|
Recall it is a best practice to package each flow definition in a unique directory.
|
|
This improves modularity, allowing dependent resources to be packaged with the flow definition.
|
|
It also prevents two flows from having the same identifiers when using the convention.
|
|
</para>
|
|
</tip>
|
|
<para>
|
|
If no base path is not specified or if the flow definition is directly on the base path, flow id assignment from the filename (minus the extension) is used.
|
|
For example, if a flow definition file is 'booking.xml', the flow identifier is simply 'booking'.
|
|
</para>
|
|
<para>
|
|
Location patterns are particularly powerful when combined with a registry base path.
|
|
Instead of the flow identifiers becoming '*-flow', they will be based on the directory path.
|
|
For example:
|
|
</para>
|
|
<programlisting language="xml"><![CDATA[
|
|
<webflow:flow-registry id="flowRegistry" base-path="/WEB-INF">
|
|
<webflow:flow-location-pattern value="/**/*-flow.xml" />
|
|
</webflow:flow-registry>]]>
|
|
</programlisting>
|
|
<para>
|
|
In the above example, suppose you had flows located in <code>/user/login</code>, <code>/user/registration</code>, <code>/hotels/booking</code>, and <code>/flights/booking</code> directories within <code>WEB-INF</code>,
|
|
you'd end up with flow ids of <code>user/login</code>, <code>user/registration</code>, <code>hotels/booking</code>, and <code>flights/booking</code>, respectively.
|
|
</para>
|
|
</sect2>
|
|
<sect2 id="flow-registry-parent">
|
|
<title>Configuring FlowRegistry hierarchies</title>
|
|
<para>
|
|
Use the <code>parent</code> attribute to link two flow registries together in a hierarchy.
|
|
When the child registry is queried, if it cannot find the requested flow it will delegate to its parent.
|
|
</para>
|
|
<programlisting language="xml"><![CDATA[
|
|
<!-- my-system-config.xml -->
|
|
<webflow:flow-registry id="flowRegistry" parent="sharedFlowRegistry">
|
|
<webflow:flow-location path="/WEB-INF/flows/booking/booking.xml" />
|
|
</webflow:flow-registry>
|
|
|
|
<!-- shared-config.xml -->
|
|
<webflow:flow-registry id="sharedFlowRegistry">
|
|
<!-- Global flows shared by several applications -->
|
|
</webflow:flow-registry>]]>
|
|
</programlisting>
|
|
</sect2>
|
|
<sect2 id="flow-registry-builder-services">
|
|
<title>Configuring custom FlowBuilder services</title>
|
|
<para>
|
|
Use the <code>flow-builder-services</code> attribute to customize the services and settings used to build flows in a flow-registry.
|
|
If no flow-builder-services tag is specified, the default service implementations are used.
|
|
When the tag is defined, you only need to reference the services you want to customize.
|
|
</para>
|
|
<programlisting language="xml"><![CDATA[
|
|
<webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices">
|
|
<webflow:flow-location path="/WEB-INF/flows/booking/booking.xml" />
|
|
</webflow:flow-registry>
|
|
|
|
<webflow:flow-builder-services id="flowBuilderServices" />]]>
|
|
</programlisting>
|
|
<para>
|
|
The configurable services are the <code>conversion-service</code>, <code>expression-parser</code>, and <code>view-factory-creator</code>.
|
|
These services are configured by referencing custom beans you define. For example:
|
|
</para>
|
|
<programlisting language="xml"><![CDATA[
|
|
<webflow:flow-builder-services id="flowBuilderServices"
|
|
conversion-service="conversionService"
|
|
expression-parser="expressionParser"
|
|
view-factory-creator="viewFactoryCreator" />
|
|
|
|
<bean id="conversionService" class="..." />
|
|
<bean id="expressionParser" class="..." />
|
|
<bean id="viewFactoryCreator" class="..." />]]>
|
|
</programlisting>
|
|
<sect3 id="builder-service-conversion">
|
|
<title>conversion-service</title>
|
|
<para>
|
|
Use the <code>conversion-service</code> attribute to customize the <code>ConversionService</code> used by the Web Flow system.
|
|
Converters are used to convert from one type to another when required during flow execution.
|
|
The default ConversionService registers converters for your basic object types such as numbers, classes, and enums.
|
|
</para>
|
|
</sect3>
|
|
<sect3 id="builder-service-expression-parser">
|
|
<title>expression-parser</title>
|
|
<para>
|
|
Use the <code>expression-parser</code> attribute to customize the <code>ExpressionParser</code> used by the Web Flow system.
|
|
The default ExpressionParser uses the Unified EL if available on the classpath, otherwise OGNL is used.
|
|
</para>
|
|
</sect3>
|
|
<sect3 id="builder-service-view-factory-creator">
|
|
<title>view-factory-creator</title>
|
|
<para>
|
|
Use the <code>view-factory-creator</code> attribute to customize the <code>ViewFactoryCreator</code> used by the Web Flow system.
|
|
The default ViewFactoryCreator produces Spring MVC ViewFactories capable of rendering JSP, Velocity, and Freemarker views.
|
|
</para>
|
|
</sect3>
|
|
<para>
|
|
The configurable settings are <code>development</code>.
|
|
These settings are global configuration attributes that can be applied during the flow construction process.
|
|
</para>
|
|
<sect3 id="builder-development">
|
|
<title>development</title>
|
|
<para>
|
|
Set this to <code>true</code> to switch on flow <emphasis>development mode</emphasis>.
|
|
Development mode switches on hot-reloading of flow definition changes, including changes to dependent flow resources such as message bundles.
|
|
</para>
|
|
</sect3>
|
|
</sect2>
|
|
</sect1>
|
|
<sect1 id="flow-executor">
|
|
<title>flow-executor options</title>
|
|
<para>
|
|
This section explores flow-executor configuration options.
|
|
</para>
|
|
<sect2 id="flow-executor-execution-listeners">
|
|
<title>Attaching flow execution listeners</title>
|
|
<para>
|
|
Use the <code>flow-execution-listeners</code> element to register listeners that observe the lifecycle of flow executions:
|
|
</para>
|
|
<programlisting language="xml"><![CDATA[
|
|
<flow-execution-listeners>
|
|
<listener ref="securityListener"/>
|
|
<listener ref="persistenceListener"/>
|
|
</flow-execution-listeners>]]>
|
|
</programlisting>
|
|
<para>
|
|
You may also configure a listener to observe only certain flows:
|
|
</para>
|
|
<programlisting language="xml"><![CDATA[
|
|
<listener ref="securityListener" criteria="securedFlow1,securedFlow2"/>]]>
|
|
</programlisting>
|
|
</sect2>
|
|
<sect2 id="tuning-flow-execution-repository">
|
|
<title>Tuning FlowExecution persistence</title>
|
|
<para>
|
|
Use the <code>flow-execution-repository</code> element to tune flow execution persistence settings:
|
|
</para>
|
|
<programlisting language="xml"><![CDATA[
|
|
<flow-execution-repository max-executions="5" max-execution-snapshots="30" />]]>
|
|
</programlisting>
|
|
<sect3 id="repository-max-executions">
|
|
<title>max-executions</title>
|
|
<para>
|
|
Tune the <code>max-executions</code> attribute to place a cap on the number of flow executions that can be created per user session.
|
|
</para>
|
|
</sect3>
|
|
<sect3 id="repository-max-snapshots">
|
|
<title>max-execution-snapshots</title>
|
|
<para>
|
|
Tune the <code>max-execution-snapshots</code> attribute to place a cap on the number of history snapshots that can be taken per flow execution.
|
|
To disable snapshotting, set this value to 0. To enable an unlimited number of snapshots, set this value to -1.
|
|
</para>
|
|
</sect3>
|
|
</sect2>
|
|
</sect1>
|
|
</chapter> |