Conversation and ORM <ul><li>Introduction to conversation
Nested conversations
Page flow and back button
Persistence context
JPA ”delegate”
Exception handling
Q&A </li></ul>
Conversations <ul><li>Keep objects for linked pages or actions
Transparently propogates the state of objects
No issues with concurrent states
Back button support
Full management by API </li></ul>
Upcoming SlideShare
Loading in...5
×

JBoss seam 2 part

1,896

Published on

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

  • Be the first to like this

No Downloads
Views
Total Views
1,896
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
11
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

JBoss seam 2 part

  1. 1. Conversation and ORM <ul><li>Introduction to conversation
  2. 2. Nested conversations
  3. 3. Page flow and back button
  4. 4. Persistence context
  5. 5. JPA ”delegate”
  6. 6. Exception handling
  7. 7. Q&A </li></ul>
  8. 8. Conversations <ul><li>Keep objects for linked pages or actions
  9. 9. Transparently propogates the state of objects
  10. 10. No issues with concurrent states
  11. 11. Back button support
  12. 12. Full management by API </li></ul>
  13. 13. Conversation's lifecycle <ul><li>Temporary conversation is exists
  14. 14. Restore at the end of restore view phase of JSF (cid=xxx - request parameter)
  15. 15. @Begin starts a long-running conversation
  16. 16. @End finishes a long-running conversation
  17. 17. Store at the end of render phase of JSF
  18. 18. Destroy the contents of a temporary conversation
  19. 19. Any faces requests will propogate the conversation context </li></ul>
  20. 20. Simple example <ul>@Name(”invoiceAction”) @AutoCreate @Scope(CONVERSATION) public class InvoiceAction implements Serializable { <ul>private Invoice currentInvoice; @Begin public void start(Long invoiceId) { currentInvoice = em.find(Invoice.class, invoiceId) } @End(beforeRedirect = true) public String update() { em.merge(currentInvoice); return ”success”; } } </ul></ul>
  21. 21. How to start conversation <ul><li>@Begin, @Begin(nested=true), @Begin(join=true)
  22. 22. <begin-conversation/> in pages.xml
  23. 23. <s:link propogation=”?”/>, <s:button propogation=”?”/>
  24. 24. <s:conversationPropogation/> for <h:commandLink/>, <h:commandButton/>
  25. 25. Conversation.instance().begin() </li></ul>
  26. 26. How to finish conversation <ul><li>@End
  27. 27. <end-conversation/> in pages.xml
  28. 28. <s:link propogation=”end”/>, <s:button propogation=”end”/>
  29. 29. <s:conversationPropogation type=”end”/>
  30. 30. Conversation.instance().end() </li></ul>
  31. 31. Nested conversation <ul><li>Conversation stack
  32. 32. No affects for outjected values with same name
  33. 33. Injection by conversation stack
  34. 34. Parent conversation finishes all nested conversations </li></ul>
  35. 35. Page flow <ul><page view-id=&quot;/numberGuess.jsp&quot; no-conversation-view-id=”/main.jsp” login-required=”true” scheme=”http”> <restrict>#{s:hasRole('admin')}</restrict> <navigation> <rule if-outcome=&quot;guess&quot;> <begin-conversation/> <redirect view-id=&quot;/numberGuess.jsp&quot;/> </rule> <rule if-outcome=&quot;win&quot;> <end-conversation before-redirect=”true”/> <redirect view-id=&quot;/win.jsp&quot;/> </rule> <rule if=&quot;#{seamComponent.check}&quot;> <redirect view-id=&quot;/lose.jsp&quot;/> </rule> </navigation> </page> </ul>
  36. 36. Back button <ul><li><page name=&quot;checkout&quot;
  37. 37. view-id=&quot;/checkout.xhtml&quot;
  38. 38. back=&quot;enabled&quot;/>
  39. 39. Nested conversations </li></ul>
  40. 40. Extended persistence context <ul><li>Pattern ”open session in view” is obsolete
  41. 41. Increase scope of persistence context to conversation scope
  42. 42. Optimized for EJB containers
  43. 43. @PersistenceContext
  44. 44. @In
  45. 45. private EntityManager entityManager; </li></ul>
  46. 46. JPA ”delegate” <ul><li>(Session) entityManager.getDelegate()
  47. 47. <factory name=&quot;session&quot;
  48. 48. scope=&quot;STATELESS&quot;
  49. 49. auto-create=&quot;true&quot;
  50. 50. value=&quot;#{entityManager.delegate}&quot;/>
  51. 51. @In
  52. 52. private Session session; </li></ul>
  53. 53. Managing exceptions <ul><li>@ApplicationException(rollback=true, message=”some text”)
  54. 54. PersistenceException </li></ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×