JBoss Seam 1 part

2,791 views

Published on

Published in: Technology
1 Comment
1 Like
Statistics
Notes
No Downloads
Views
Total views
2,791
On SlideShare
0
From Embeds
0
Number of Embeds
648
Actions
Shares
0
Downloads
48
Comments
1
Likes
1
Embeds 0
No embeds

No notes for slide

JBoss Seam 1 part

  1. 1. JBoss Seam <ul><li>Introduction
  2. 2. The contextual component model
  3. 3. Bijections
  4. 4. Lifecycle methods
  5. 5. Events and interceptors
  6. 6. Exception handling
  7. 7. Links
  8. 8. Q&A </li></ul>
  9. 9. Introduction <ul>Seam principles: <li>One kind of ”stuff”
  10. 10. Integrated JSF and EJB 3.0
  11. 11. Declarative state management
  12. 12. Business process as a first class construct
  13. 13. Bijection
  14. 14. Conversations and multi-window browsing
  15. 15. Prefer annotations to XML
  16. 16. Integration testing is easy </li></ul>
  17. 17. Seam contexts <ul><li>Stateless context
  18. 18. Event (i.e, request) context
  19. 19. Page (instance of rendered page) context
  20. 20. Conversation context
  21. 21. Session context
  22. 22. Business process context
  23. 23. Application context </li></ul>
  24. 24. Seam components <ul><li>EJB 3.0 stateless session beans
  25. 25. EJB 3.0 stateful session beans
  26. 26. EJB 3.0 entity beans (i.e, JPA entity classes)
  27. 27. JavaBeans
  28. 28. EJB 3.0 message-driven beans
  29. 29. Spring beans </li></ul>
  30. 30. Bijection <ul><li>Contextual
  31. 31. Bidirectional
  32. 32. Dynamic
  33. 33. @In(value=”#{el.expression}”, create=?, required=?, scope=?)
  34. 34. @Out(value=”#{el.expression}”, required=?, scope=?) </li></ul>
  35. 35. Factory and manager components <ul><li>@Factory(value=”#{el.expression}”, scope=?) </li><ul><li>@Factory(”customerList”)
  36. 36. public List<Customer> getCustomerList() {
  37. 37. return …;
  38. 38. } </li></ul><li>@Unwrap
  39. 39. @Name(”customerList”)
  40. 40. @Scope(CONVERSATION)
  41. 41. public class CustomerListManager { </li><ul><li>@Unwrap
  42. 42. public List<Customer> getCustomerList() {
  43. 43. return …;
  44. 44. } </li></ul><li>} </li></ul>
  45. 45. Lifecycle methods <ul><li>@Create
  46. 46. @Destroy
  47. 47. @Startup(depends = {?})
  48. 48. @Install </li></ul>
  49. 49. Seam events <ul><li>JSF events
  50. 50. jBPM transition events
  51. 51. Seam page actions
  52. 52. Seam component-driven events
  53. 53. Seam contextual events </li></ul>
  54. 54. JSF and Page actions Example: <h:commandButton value=&quot;Click me!&quot; action=&quot;#{helloWorld.sayHello}&quot;/> <pages> <page view-id=&quot;/hello.jsp&quot; action=&quot;#{helloWorld.sayHello}&quot;> <param name=&quot;firstName&quot; value=&quot;#{person.firstName}&quot;/> <param name=&quot;lastName&quot; value=&quot;#{person.lastName}&quot;/> </page> </pages>
  55. 55. Component-driven events <ul><li>@RaiseEvent(”hello”)
  56. 56. @Observer(”hello”)
  57. 57. Events.instance().raiseEvent(”hello”) </li></ul>
  58. 58. Contextual events <ul><li>org.jboss.seam.validationFailed — called when JSF validation fails
  59. 59. org.jboss.seam.preSetVariable.<name> — called when the context variable <name> is set
  60. 60. org.jboss.seam.postSetVariable.<name> — called when the context variable <name> is set
  61. 61. org.jboss.seam.preRemoveVariable.<name> — called when the context variable <name> is unset
  62. 62. org.jboss.seam.postRemoveVariable.<name> — called when the context variable <name> is unset
  63. 63. org.jboss.seam.preDestroyContext.<SCOPE> — called before the <SCOPE> context is destroyed
  64. 64. org.jboss.seam.postDestroyContext.<SCOPE> — called after the <SCOPE> context is destroyed
  65. 65. org.jboss.seam.postCreate.<name> — called when the component <name> is created
  66. 66. org.jboss.seam.preDestroy.<name> — called when the component <name> is destroyed
  67. 67. org.jboss.seam.exceptionHandled.<type> — called when an uncaught exception is handled by Seam
  68. 68. org.jboss.seam.exceptionHandled — called when an uncaught exception is handled by Seam
  69. 69. org.jboss.seam.exceptionNotHandled — called when there was no handler for an uncaught exception </li></ul>
  70. 70. Interceptors @Interceptor(around = {BijectionInterceptor.class, ValidationInterceptor.class}) public class InterceptorName { @AroundInvoke public Object methodName(InvocationContext invocation) throws Exception { … Object result = invocation.proceed() ... } } @Interceptors(InterceptorName.class, stateless=true) Or @Target(TYPE) @Retention(RUNTIME) @Interceptors(InterceptorName.class) public @interface CustomAnnotation {}
  71. 71. Managing exceptions <ul><li>@ApplicationException(rollback=true, message=”some text”)
  72. 72. @HttpError(errorCode=404)
  73. 73. @Redirect(viewId=”/error.xhtml”, end=true)
  74. 74. <exception class=&quot;javax.persistence.PersistenceException&quot;>
  75. 75. <end-conversation/>
  76. 76. <redirect view-id=&quot;/error.xhtml&quot;>
  77. 77. <message>Database access failed</message>
  78. 78. </redirect>
  79. 79. </exception> </li></ul>
  80. 80. Links <ul><li>http://seamframework.org/
  81. 81. http://docs.jboss.org/seam/latest/reference/en-US/html/Book-Preface.html
  82. 82. http://seamframework.org/Seam2/Downloads </li></ul>

×