码迷,mamicode.com
首页 > 移动开发 > 详细

SPRING IN ACTION 第4版笔记-第八章Advanced Spring MVC-001- 配置SpringFlow(flow-executor、flow-registry、FlowHandlerMapping、FlowHandlerAdapter)

时间:2016-03-06 15:34:09      阅读:291      评论:0      收藏:0      [点我收藏+]

标签:

一、

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 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 executor.

(1)通配符<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 will 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 will
be considered a flow definition.

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

技术分享

或者

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)明确位置 <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 this way, the flow’s ID is derived from the base name of the flow definition file, springpizza in this case.

或者指定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)装配FlowHandlerMapping,告诉DispatcherServlet,把flow交给它处理

DispatcherServlet typically dispatches requests to controllers. But for flows, you need a FlowHandlerMapping to help DispatcherServlet know that it should send flow requests to Spring Web Flow

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

As you can see, the FlowHandlerMapping is wired with a reference to the flow registry so it knows when a request’s URL maps to a flow. For example, if you have a flow whose ID is pizza , then FlowHandlerMapping will know to map a request to that flow if the request’s URL pattern (relative to the application context path) is /pizza.

(2)装配FlowHandlerAdapter

Whereas the FlowHandlerMapping ’s job is to direct flow requests to Spring Web Flow, it’s the job of a  FlowHandlerAdapter to answer that call. A FlowHandlerAdapter is equivalent to a Spring MVC controller in that it handles 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 requests.

SPRING IN ACTION 第4版笔记-第八章Advanced Spring MVC-001- 配置SpringFlow(flow-executor、flow-registry、FlowHandlerMapping、FlowHandlerAdapter)

标签:

原文地址:http://www.cnblogs.com/shamgod/p/5247536.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!