A new world with cdi en

2,844 views
2,681 views

Published on

An essay around some of the design changes encouraged by CDI + Seam 3

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

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

No notes for slide

A new world with cdi en

  1. 1. A new world with CDI An essay around some of the design changes encouraged by CDI + Seam 3Monday, May 16, 2011
  2. 2. Who am I ? • Software developer at R&D department at Softplan in Brazil • Seam 3 Contributor • Hobbyist game programmer • CIA spy (it’s a secret, don’t tell anyone)Monday, May 16, 2011
  3. 3. AgendaMonday, May 16, 2011
  4. 4. Agenda • ContextualizationMonday, May 16, 2011
  5. 5. Agenda • Contextualization • A quickly introduction to CDIMonday, May 16, 2011
  6. 6. Agenda • Contextualization • A quickly introduction to CDI • A real quickly introduction on Seam 3Monday, May 16, 2011
  7. 7. Agenda • Contextualization • A quickly introduction to CDI • A real quickly introduction on Seam 3 • Design simplicity with CDIMonday, May 16, 2011
  8. 8. ContextualizationMonday, May 16, 2011
  9. 9. A little of web application historyMonday, May 16, 2011
  10. 10. The rise of Java • CGI • Servlet • Servlet + JSP • Templating, tag libraries • The era of frameworksMonday, May 16, 2011
  11. 11. Struts, Hibernate, Spring • It was almost impossible to develop an application with pure J2EE • Different frameworks to approach different application development needs • Data abstractions • IoC • Flow controlMonday, May 16, 2011
  12. 12. JEE 5 • JPA • EJB3 • JSF1.2 • Annotations • ...Monday, May 16, 2011
  13. 13. Seam • The Glue between JSF and EJB • Context management and DIMonday, May 16, 2011
  14. 14. The Real story • A king tired of lazyInitializationExceptionsMonday, May 16, 2011
  15. 15. Have you seen similar method names? • getCustomerWithAddress() • getCustomerWithFoo() • getCustomerWithFooAndBar()Monday, May 16, 2011
  16. 16. JEE6 • CDI • JSF2 • JPA2 • EJB3.1 • ...Monday, May 16, 2011
  17. 17. CDI main goals • The Standard glue between JSF and EJB • Injectable beans with Managed lifecycle • loose coupling • TypeSafe • AOP and EventsMonday, May 16, 2011
  18. 18. “CDI simplifies and sanitizes the API for DI and AOP”Monday, May 16, 2011
  19. 19. “CDI simplifies and sanitizes the API for DI and AOP” Rick HightowerMonday, May 16, 2011
  20. 20. “CDI rulez!”Monday, May 16, 2011
  21. 21. “CDI rulez!” meMonday, May 16, 2011
  22. 22. “Designing with CDI is a road to be discovered, specially when we consider the event handling feature”Monday, May 16, 2011
  23. 23. “Designing with CDI is a road to be discovered, specially when we consider the event handling feature” me tooMonday, May 16, 2011
  24. 24. And seam? what is seam now after it externalized the CDI?Monday, May 16, 2011
  25. 25. Seam’s mission is to provide a fully- integrated development platform for building rich, standards-based internet applications tailored for traditional and cloud developmentMonday, May 16, 2011
  26. 26. Now we can beginMonday, May 16, 2011
  27. 27. Monday, May 16, 2011
  28. 28. Pragmatics approachMonday, May 16, 2011
  29. 29. ECB Pattern • Entity - Control - Boundary EJB CDI Bean JPAMonday, May 16, 2011
  30. 30. CEC Pattern • CDI - EJB - CDI EJB CDI Bean JPAMonday, May 16, 2011
  31. 31. CEC Pattern • CDI - EJB - CDI EJB CDI Bean JPAMonday, May 16, 2011
  32. 32. CEC Pattern • CDI - EJB - CDI CDI bean EJB CDI Bean JPAMonday, May 16, 2011
  33. 33. CEC Pattern • CDI - EJB - CDI Presenter CDI bean EJB CDI Bean JPAMonday, May 16, 2011
  34. 34. SimplicityMonday, May 16, 2011
  35. 35. Goals • Clean design • Less coding, less bugs • Higher productivity • Easier test automationMonday, May 16, 2011
  36. 36. Common designMonday, May 16, 2011
  37. 37. javaee 5Monday, May 16, 2011
  38. 38. javaee 6Monday, May 16, 2011
  39. 39. Easy boy! the world won’t endMonday, May 16, 2011
  40. 40. Keeps the served list and provides it to the view through EL Renders a list Returns a listMonday, May 16, 2011
  41. 41. Renders a list Returns a listMonday, May 16, 2011
  42. 42. And what about the actions?Monday, May 16, 2011
  43. 43. Problems: • Messages to the view • Flow controlMonday, May 16, 2011
  44. 44. Messages to UI • Proposed solution : Seam MessagesAPIMonday, May 16, 2011
  45. 45. Flow control • Success and Error: the typical case • Validation can be done before the service with Bean Validations • In case of exceptions it could be handled by a decoupled class (Seam Catch )Monday, May 16, 2011
  46. 46. Complex cases: JSF Nav. RulesMonday, May 16, 2011
  47. 47. xml??Monday, May 16, 2011
  48. 48. xml navigation pros • More flexible than implicity navigation • IMO, returning a string as outcome is bad • Clean solution to totally abstract a flow controller • It is tool friendly • ...Monday, May 16, 2011
  49. 49. Let the structure do its work JSF2 complete Reference, page 12 • JSF CompleteMonday, May 16, 2011
  50. 50. Monday, May 16, 2011
  51. 51. what about presentation logic?Monday, May 16, 2011
  52. 52. Model View PresenterMonday, May 16, 2011
  53. 53. Be careful! • take a closer look at your case • choose to simplify whenever is possible.Monday, May 16, 2011
  54. 54. Basic references • http://seamframework.org/ • http://www.jcp.org/en/jsr/detail?id=299 • http://www.adam-bien.com/Monday, May 16, 2011
  55. 55. Thank you! • Contact: José Rodolfo Freitas joserodolfo.freitas@gmail.com • Supported by: Softplan/Poligraph http://talentos.softplan.com.br • Follow on Twitter: @joserodolfo_f • Blog techblog.joserodolfo.comMonday, May 16, 2011

×