Spring in ACTION 4th Edition notes-eighth chapter advanced Spring mvc-001-Configuration Springflow (Flow-executor, Flow-registry, flowhandlermapping, Flowhandleradapter)

Source: Internet
Author: User

One

1.Wiring a flow Executor

<flow:flow-executor id= "Flowexecutor"/>

Although the flow executor is responsible for creating and executing flows, it 's not responsible for loading flow Definitions. That's responsibility falls to a flow Registry,which you ' ll create next.

2.Configuring a flow registry

A Flow registry ' s job is to load flow definitions and make them available to the flow exec Utor.

(1) wildcard characters <flow:flow-location-pattern>

1 <flow:flow-registry id= "Flowregistry" base-path= "/web-inf/flows" >2     <flow: Flow-location-pattern value= "*-flow.xml"/>3 </flow:flow-registry>

as declared here, the flow registry would look for flow definitions under the /web-inf/flows directory, as specified in the Base-path attribute. Per the <flow:flow-location-pattern> element, any XML file whose name ends With-flow.xml would
be considered a flow definition.

All flows is referred to by their ID s. Using <flow:flow-location-pattern> as you had, the flow ID is the directory
path relative to the base-path-or the Part of the path represented with the double asterisk

Or

1   <!--the registry of executable flow definitions--2   <flow:flow-registry id= "Flowregistry" Base-path= "/web-inf/flows" >3      <flow:flow-location-pattern value= "/**/*-flow.xml"/>  4   </flow:flow-registry>

(2) Clear location <flow:flow-location>

1 <flow:flow-registry id= "Flowregistry" >2     <flow:flow-location path= "/web-inf/flows /springpizza.xml "/>3 </flow:flow-registry>

When configured the "This", the flow ' s ID is derived from the base name of the flow definition file, Springpizza in this case.

or specify an ID

1 <flow:flow-registry id= "Flowregistry" >2     <flow:flow-location id= "pizza" path= "/ Web-inf/flows/springpizza.xml "/>3 </flow:flow-registry>

3.Handling Flow Requests

(1) Assemble the flowhandlermapping and tell Dispatcherservlet to hand flow to it.

Dispatcherservlet typically dispatches requests to controllers. But for flows, you need a flowhandlermapping to the help Dispatcherservlets know that it should send flow requests to Spring Web Flow

1 <!--Maps request paths to flows in the flowregistry-->2   class= " Org.springframework.webflow.mvc.servlet.FlowHandlerMapping ">3     <property name=" Flowregistry " ref= "Flowregistry"/>4   </bean>

as can see, the flowhandlermapping are wired with a reference to the flow registry So it knows when a request ' s URL maps to a flow. For example, if you had a flow whose ID is pizza and then flowhandlermapping would know to map a request to that FL ow if the request ' s URL pattern (relative to the application context path) Is/pizza.

(2) Assembly Flowhandleradapter

whereas the flowhandlermapping ' s job is to direct flow requests to Spring WEB&NBSP;flow, it's the job of a  flowhandleradapter to answer this call. a flowhandleradapter  is equivalent to a Spring MVC controller in that it Handl Es requests coming in for a  flow and processes those requests.

 1  <!--2   Dispatches requests mapped to flows to Flowhandler implementations  3 -->4  <bean class  = " Org.springframework.webflow.mvc.servlet.FlowHandlerAdapter ">5  < Property Name= "Flowexecutor" ref= "Flowexecutor"/>6  </bean> 

This handler adapter is the bridge between Dispatcherservlet and Spring Web Flow. It handles flow requests and manipulates the flow based on those requests. Here, it 's wired with a reference to the flow executor-to- execute the flows for which it handles request S.

Spring in ACTION 4th Edition notes-eighth chapter advanced Spring mvc-001-Configuration Springflow (Flow-executor, Flow-registry, flowhandlermapping, Flowhandleradapter)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.