Flow Registry
Place where all the flow definitions in your application is stored with a unique identifier is called the Flow Registry. The flows are typically stored in your web application under the WEB-INF folder as these cannot be accessed through the browser URL. The flows can be registered one by one as shown in Listing 14-33 below or by using appropriate wildcard pattern which registers all the flows at once as shown in Listing 14-34 below.
Listing 14-33. Registering flow one by one
1 2 3 |
<webflow:flow-registry id="flowRegistry"> <webflow-flow-location id="booking" path="/WEB-INF/booking-flow.xml"/> </webflow:flow-registry> |
Listing 14-34. Registering flows at once using wildcard patterns
1 2 3 |
<webflow:flow-registry id="flowRegistry" base-path="/WEB-INF/"> <webflow-flow-location-pattern value="**/*-flow.xml"/> </webflow:flow-registry> |
The flow registeries can also have a parent-child relationship for high level of reuse as shown in Listing 14-35 below. Use the “parent” attribute in sub-flow flow registries for achieving this.
Listing 14-35. Parent-child relationship in flow registry settings
1 2 3 4 5 6 7 |
<webflow:flow-registry id="parentFlowRegistry"> <!-- Flows shared by several modules in your application --> </webflow:flow-registry> <webflow:flow-registry id="flowRegistry" parent="parentFlowRegistry"> <webflow:flow-location path="/WEB-INF/booking-flow.xml" /> </webflow:flow-registry> |
Predefined Variables
There are predefined variable which a flow can reference as the case may be. These can be summarized as shown in Table 14-5 below.
Table 14-5. Predefined variables which can be used in Spring Web Flow
Predefined Variable | Description |
resourceBundle | Used to get text messages configured in the properties file inside the flow configuration |
messageContext | The context which the text message uses to get the various details |
requestParameters | To access the HTTP request parameters |
currentUser | Variable storing the executing user’s principal attributes |
currentEvent | Variable storing the attributes of current event being executed |
flowRequestContext | Similar to message context, this variable gives the context of the flow request being executed |
flowExecutionContext | Variable storing the context of the flow execution |
flowExecutionUrl | The URL of the current view-state |
externalContext | The context which is external to the flow |
Securing Web Flow
Spring Web Flow integrates well with the famous Spring Security project in all aspects. Once the integration is made, you can use the <secured> tag to achieve security in “states”, “transitions” and “flows” of Spring Web Flow as shown in Listing 14-36 below as a sample.
Listing 14-36. Achieving security in Spring Web Flow
1 2 3 4 5 6 7 8 9 10 11 |
… <view-state id="submitBooking"> <transition on="next" to="enterAddress"/> <transition on="submit" to="loyaltyPoints"/> </view-state> <subflow-state id="loyaltyPoints" subflow="showLoyaltyPoints"> <secured attributes="ROLE_AUTHENTICATED"/> <attribute name="user" value="booking.user"/> <transition to="bookingConfirmation"/> </subflow-state> … |
If the user doesn’t have the necessary credentials to access, AccessDeniedException is throws and according to the Spring Secuirty configuration, it will be handled accordingly.
Page Visitors: 8013
Tomcy John
Latest posts by Tomcy John (see all)
- A Guide to Continuous Improvement for Architects - February 2, 2023
- Cloud-first Architecture Strategy - January 26, 2023
- Architecture Strategy and how to create One - January 24, 2023