Spring Web flow. A little flow of happiness

2,696 views

Published on

Presentation from JEEConf 2013 conference.

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,696
On SlideShare
0
From Embeds
0
Number of Embeds
649
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Spring Web flow. A little flow of happiness

  1. 1. Spring Web Flow:A little flow of happiness.Сергей Моренец, morenets@mail.ru24 мая 2013 г.
  2. 2. About author• Works in IT since 2000• 9 year of Java SE/EE experience• 5 years of Spring (including SWF) usage• Regular speaker on Java User Group conferences• Senior Java developer in Provectus
  3. 3. Agenda• Overview of the navigation history• Basics of SWF• Practical usage• Pros & Contras• Q & A
  4. 4. Spring MVC
  5. 5. Navigation overview• JSP• Spring MVC• Struts• JSF
  6. 6. JSP
  7. 7. Spring MVC
  8. 8. Strutsstruts-config.xml
  9. 9. JSFfaces-config.xml
  10. 10. Disadvantages• Visualizing the flow is very difficult• Mixed navigation and view• Overall navigation rules complexity• All-in-one navigation storage• Lack of state control/navigation customization
  11. 11. What is Spring Web Flow?• Developed by Erwin Vervaet in 2004• Initial version released in October, 2006• Spring MVC extension• Introduces flows concept• Extends application scopes• SWF 2.3.2 released in Jan, 2013
  12. 12. Erwin Vervaet• Belgium citizen• Holds masters degree in computer science• Originator of Spring Web Flow Project• Senior project manager together with Keith Donald• Speaker on the most Java and Spring relatedthemes• Independent consultant www.ervacon.com
  13. 13. What is SWF for?• How do you express page navigation rules?• How do you manage navigation and conversationalstate?• How do you facilitate modularization and reuse?
  14. 14. Use case
  15. 15. Request diagram
  16. 16. Request diagram
  17. 17. Flow definition• XML document with predefined elements• Flow definition is composed of a set of states• Each state has one or more transitions that are used tomove to another state• A transition is triggered by an event
  18. 18. Flow StructureFlowTransitionsDataStates
  19. 19. State typeStateAction View Subflow Decision End
  20. 20. Action state
  21. 21. View state
  22. 22. Decision state
  23. 23. Subflow state
  24. 24. End state
  25. 25. Start/end activity
  26. 26. Transition binding• JSF• Spring MVC
  27. 27. JSF
  28. 28. Spring MVC
  29. 29. Post redirect get(PRG)
  30. 30. Spring scopeSingletonRequestGlobal-sessionSessionPrototype
  31. 31. SWF scopeRequestViewConversationFlowFlash
  32. 32. Request scope• Tied at the level of a single request• Not linked to a flow execution by itself
  33. 33. Flash scope• Extended request scope for PRG case• Useful for rendering error/warning messages
  34. 34. View scope• Can be referenced only within view state• Useful for storing data required with given view only
  35. 35. Flow scope• Lives within flow session• Not available inside sub-flows
  36. 36. Conversation scope• Lives within entire flow execution• Available to all sub-flows
  37. 37. Flow scope usage
  38. 38. View scope usage
  39. 39. Presentation level
  40. 40. Flow trackingOriginal link http://mysite/site/main?id=1Target http://mysite.com/site/main?execution=e2s1
  41. 41. Flow tracking
  42. 42. Flow tracking
  43. 43. Flow trackingOriginal link http://mysite/site/main?id=1Targethttp://mysite.com/site/main?execution=e2s1&id=1
  44. 44. Exception handling• Transition on exception• Custom exception handler
  45. 45. Transition on exception
  46. 46. Exception handler
  47. 47. Exception handler
  48. 48. Flow inheritanceParent-flowChild-flow
  49. 49. Shortcuts• requestParameters• currentEvent• currentUser• messageContext• resourceBundle• flowRequestContext
  50. 50. Breadcrumbs• Navigation elements in UI• Allows to keep track of the documents withinsystem• Provide links to move to current, previous or nextstep• Home page > Section page > Subsection page
  51. 51. Breadcrumbs
  52. 52. Breadcrumbs
  53. 53. Breadcrumbs
  54. 54. Breadcrumbs
  55. 55. Distribution
  56. 56. Integration• Spring MVC/Spring Security• Apache MyFaces• JSF 2• Portlets• RichFaces• Struts 2• Tiles
  57. 57. Future• Suspend/resume functionality• Backtracking support• Flows deployment as OSGi bundles• Native support for Tiles and FreeMarker• URL rewriting• Java-based flow definition syntax
  58. 58. Pros• High-level navigation control with clear observablelifecycle• Designed to be self contained• Compile-independent• Easy to understand and visualize• Expression language support• Custom validation (including AJAX)• Integrates with major web frameworks
  59. 59. Cons• Requires Spring framework• Separate Spring project• Additional performance overhead• Lack of community support• Not suitable for simple or flow-free applications
  60. 60. Spring Tools Suite• Eclipse development environment for buildingSpring-powered enterprise applications• Visualization of Spring Web Flow• Flow graph• Flow editor
  61. 61. References
  62. 62. Q&AСергей Моренец, morenets@mail.ru

×