Your SlideShare is downloading. ×
0
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Voodoo architecture
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Voodoo architecture

448

Published on

Java EE Voodoo Architecture …

Java EE Voodoo Architecture
Speaker: Lars Röwekamp

Die Bordmittel von Java EE ermöglicht Architekturen, von denen man zu Zeiten von J2EE nur träumen durfte. Nahezu losgelöst von technologischen und schichtenbedingten Restriktionen kommen völlig neue Patterns zum Tragen. Im Gegenzug dazu kann auf "lieb gewonnene" Workarounds - aka J2EE-Pattern - verzichtet werden. Die Session gibt einen Einblick in die vielfältigen Möglichkeiten und möchte so zu neuen Denkmustern im Java-EE-Architekturdesign anregen.


Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
448
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
9
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Voodoo
 Architecture
 @mobileLarson 
 @_openKnowledge Lars Röwekamp | CIO New Technologies
  • 2. „Fachlichkeit im Fokus!“ ! „Java EE 6 und 7 erlauben neben Infrastructure Injection auch Business Injection.“ Was sie mitnehmen sollten ... Voodoo powered Enterprise Architecture
  • 3. Ok, was heißt das?
  • 4. Voodoo powered Call Center Anwendung ! ‣ Kunde neu erfassen und speichern ‣ Call Center Agent als Audit Info mit speichern ‣ Begrüßungs-EMail an Neukunden versenden ! ‣ Kunde löschen inkl. Sicherheitsabfrage ‣ Call Center Agent als Audit Info mit speichern ‣ EMail an ehemaligen Kunden versenden Der Use Case Enterprise Architecture
  • 5. Old School
  • 6. Voodoo powered Use Case: Kunde neu erfassen ! ‣ JSF View ruft UI Controller via U-EL ‣ UI Controller ruft CustomerService EJB ‣ UI Controller ruft MailService EJB Enterprise Architecture Old School Ansatz
  • 7. Voodoo powered Enterprise Architecture Old School Ansatz UI Service Data JSF View CreateCustomer CustService MailService Customer Mail
  • 8. Enterprise Architecture Old School Ansatz // JSF UI Controller! @javax.faces.bean.RequestScoped! @javax.faces.bean.ManagedBean(name=“createCustomerController“)! public class CreateCustomerController {! ! @EJB! private CustomerService customerService; ! ! @EJB ! private MailService mailService; ! ! private Customer customer; ! ! public String createCustomer() {! customerService.create(customer); ! mailService.sendWelcomeMail(customer); ! return CUSTOMER_CREATED; ! } ! ! // getter / setter for customer! ...! }! Und was ist mit dem 
 Call Center Agent? Voodoo powered
  • 9. Use Case: Kunde neu erfassen ! ‣ JSF View ruft UI Controller via U-EL ‣ UI Controller ruft CustomerService EJB ‣ UI Controller ruft MailService EJB ‣ UI Controller ruft AuthenticationController Enterprise Architecture Old School Ansatz Voodoo powered
  • 10. Enterprise Architecture Old School Ansatz JSF View CreateCustomer CCAgent AuthService Mail MailService Customer CustService AuthController Voodoo powered
  • 11. Enterprise Architecture Old School Ansatz // JSF UI Controller! @javax.faces.bean.RequestScoped! @javax.faces.bean.ManagedBean(name=“createCustomerController“)! public class CreateCustomerController {! ! // inject CustomerService and MailService via @EJB! ! @ManagedProperty(value=“#{authenticationController}“) ! private AuthenticationController authController; ! ...! ! public String createCustomer() {! CallCenterAgent currentCallCenterAgent;! currentCallCenterAgent = authController.getLoggedInUser(); ! customer.setAuditInformation(currentCallCenterAgent);! customerService.create(customer); ! mailService.sendWelcomeMail(customer); ! return CUSTOMER_CREATED;! } ! ! // getter / setter for customer! ...! }! Ok, aber wo wird die Transaktion aufgezogen? Voodoo powered
  • 12. Use Case: Kunde neu erfassen ! ‣ JSF View ruft UI Controller via U-EL ‣ UI Controller ruft AuthenticationController ‣ UI Controller ruft CustomerFacade EJB ‣ Delegate EJB ruft CustomerService EJB ‣ Delegate EJB ruft MailService EJB Enterprise Architecture Old School Ansatz Voodoo powered
  • 13. TX Enterprise Architecture Old School Ansatz CreateCustomer CustFacade AuthService CCAgent CustService MailService Customer Mail AuthController Voodoo powered
  • 14. Enterprise Architecture Old School Ansatz // JSF UI Controller! @javax.faces.bean.RequestScoped! @javax.faces.ManagedBean(name=“createCustomerController“)! public class CreateCustomerController {! ! @EJB ! private CustomerFacade customerFacade; ! ! @ManagedProperty(value=“#{authenticationController}“) ! private AuthenticationController authController; ! ! private Customer customer; ! ! public String createCustomer() {! CallCenterAgent currentCallCenterAgent;! currentCallCenterAgent = authController.getLoggedInUser(); ! customerFacade.create(customer, currentCallCenterAgent); ! return CUSTOMER_CREATED;! } ! ...! } Voodoo powered
  • 15. Enterprise Architecture Old School Ansatz // EJB Service Facade! @Stateless! public class CustomerFacade {! ! @EJB ! private CustomerService customerService! ! @EJB! private MailService mailService;! ! // Transactional by default! public void createCustomer(Customer customer, ! CallCenterAgent currentCallCenterAgent) {! customer.setAuditInformation(currentCallCenterAgent);! customerService.create(customer); ! mailService.sendWelcomeMail(customer); ! } ! ! ...! } Fühlt sich nicht gut an! Alternativen sind aber auch nicht viel schöner! Voodoo powered
  • 16. Enterprise Architecture Old School Ansatz JSF View CustService CreateCustomer AuthService CCAgent MailService Customer Mail AuthController Voodoo powered
  • 17. Use Case: Kunde löschen ! ‣ JSF View ruft UI Controller via U-EL ‣ UI Controller „merkt“ sich Kunde in Session ‣ UI Controller navigiert zu Bestätigungsseite ‣ UI Controller bekommt Bestätigung ‣ UI Controller ruft CustomerService EJB ‣ ... Enterprise Architecture Old School Ansatz Voodoo powered
  • 18. Enterprise Architecture Old School Ansatz UI Service Data JSF View 1 DeleteCustomer CustService MailService Customer Mail JSF View 2 Voodoo powered
  • 19. Enterprise Architecture Old School Ansatz // JSF UI Controller! @javax.faces.bean.SessionScoped! @javax.faces.bean.ManagedBean(name=“deleteCustomerController“)! public class DeleteCustomerController implements Serializable {! ! // @EJB CustomerService, AuthenticationService and MailService! ! private Customer customerToDelete;! ! public String askForDeletion(Customer customer) {! customerToDelete = customer; ! return SHOW_DELETE_CONFIRMATION; ! } ! ! public String deleteCustomer() {! ... // call backend services and delete customer! return CUSTOMER_DELETED; ! } ! ...! }! Wann kommt der Datensatz 
 aus der Session wieder raus? Voodoo powered
  • 20. Problemkind Schichtenmodell ! ‣ UI Controller via JSF Managed Beans ‣ Service Facade und Services via EJBs ‣ Persistenz via EntityManager und Entities ! ‣ Alles nur Infrastruktur! ‣ Wo steckt eigentlich die fachliche Domain? Enterprise Architecture Old School Ansatz Voodoo powered
  • 21. Enterprise Architecture Old School Ansatz UI Service Data JSF View @ManagedBean (JSF) Session EJB Session EJB EntityManager Entity TX Voodoo powered
  • 22. Enterprise Architecture Voodoo Ansatz UI Domain JSF View UseCaseController Business Object Business Object Business Object TX Voodoo powered
  • 23. Enterprise Architecture Voodoo Ansatz UI Domain JSF View UseCaseController Business Object Business Object Business Object TX Voodoo powered
  • 24. Time for Voodoo …

  • 25. Voodoo Steps: ! ‣ „Technology Independence“ ‣ „@Inject Business Objects“ ‣ „No more EJBs for Transactions only“ ‣ „No more pumped up Sessions“ ‣ „No more Infrastructure in Views“ ‣ „No more doAll( ) Business Methods“ Enterprise Architecture Migration Guide Voodoo powered
  • 26. Voodoo Steps: ! ‣ „Technology Independence“ ‣ „@Inject Business Objects“ ‣ „No more EJBs for Transactions only“ ‣ „No more pumped up Sessions“ ‣ „No more Infrastructure in Views“ ‣ „No more doAll( ) Business Methods“ Enterprise Architecture Migration Guide Voodoo powered
  • 27. // JSF UI Controller! @javax.faces.bean.RequestScoped! @javax.faces.bean.ManagedBean(name=“createCustomerController“)! public class CreateCustomerController {! ! // inject CustomerService and MailService via @EJB! ! @EJB ! private AuthenticationService authenticationService; ! ! private Customer customer; ! ! public String createCustomer() {! currentCallCenterAgent = authenticationService.getLoggedInUser(); ! customer.setAuditInformation(currentCallCenterAgent);! customerService.create(customer); ! mailService.sendWelcomeMail(customer); ! return CUSTOMER_CREATED;! } ! ! // getter / setter for customer! ...! }! Migration Guide Technology Independence Voodoo powered
  • 28. // JSF UI Controller! @javax.enterprise.context.RequestScoped! @javax.inject.Named(“createCustomerController“)! public class CreateCustomerController {! ! // inject CustomerService and MailService via @Inject! ! @Inject! private AuthenticationService authenticationService; ! ! private Customer customer; ! ! public String createCustomer() {! currentCallCenterAgent = authenticationService.getLoggedInUser(); ! customer.setAuditInformation(currentCallCenterAgent);! customerService.create(customer); ! mailService.sendWelcomeMail(customer); ! return CUSTOMER_CREATED;! } ! ! // getter / setter for customer! ...! }! Migration Guide Technology Independence Voodoo powered
  • 29. Voodoo Steps: ! ‣ „Technology Independence“ ‣ „@Inject Business Objects“ ‣ „No more EJBs for Transactions only“ ‣ „No more pumped up Sessions“ ‣ „No more Infrastructure in Views“ ‣ „No more doAll( ) Business Methods“ Enterprise Architecture Migration Guide Voodoo powered
  • 30. CDI Producer Methods & Fields ! ‣ Factory Method Pattern für Objekte ‣ @Producer als Mittel zum Zweck ‣ @Qualifier als Mittel zur Typ-Qualifizierung ! ‣ ermöglicht fachliche Injektion @Inject @Current CallCenterAgent Migration Guide Voodoo powered
  • 31. // JSF UI Controller! @javax.enterprise.context.RequestScoped! @javax.inject.Named(“createCustomerController“)! public class CreateCustomerController {! ! // inject CustomerService and MailService via @Inject! ! @Inject! private AuthenticationService authenticationService; ! ! private Customer customer; ! ! public String createCustomer() {! currentCallCenterAgent = authenticationService.getLoggedInUser(); ! customer.setAuditInformation(currentCallCenterAgent);! customerService.create(customer); ! mailService.sendWelcomeMail(customer); ! return CUSTOMER_CREATED;! } ! ! // getter / setter for customer! ...! }! Migration Guide @Inject @Current CallCenterAgent Voodoo powered
  • 32. // JSF UI Controller! @javax.enterprise.context.RequestScoped! @javax.inject.Named(“createCustomerController“)! public class CreateCustomerController {! ! // inject CustomerService and MailService via @Inject! ! @Inject @Current! private CallCenterAgent currentCallCenterAgent; ! ! private Customer customer; ! ! public String createCustomer() {! customer.setAuditInformation(currentCallCenterAgent);! customerService.create(customer); ! mailService.sendWelcomeMail(customer); ! return CUSTOMER_CREATED;! } ! ! // getter / setter for customer! ...! }! ! Migration Guide @Inject @Current CallCenterAgent Voodoo powered
  • 33. // Authentication Controller! @SessionScoped! @Named(“authenticationController“)! public class AuthenticationController implements Serializable {! ! private CallCenterAgent authenticatedCallCenterAgent; ! ! public String authenticate() {...}! ! @Produces @Current ! public CallCenterAgent getAuthenticatedCallCenterAgent() {! return authenticatedCallCenterAgent;! } ! ! ...! }! ! Migration Guide @Inject @Current CallCenterAgent @RequestScoped @Inject @Current CallCenterAgent Voodoo powered
  • 34. package de.openknowldege.qualifier! ! import ... ! ! // self-made qualifier to indicate current instance of something! ! @Qualifier! @Target({TYPE, METHOD, PARAMETER, FIELD})! @Retention(RUNTIME)! public @interface Current{! ! } Migration Guide @Inject @Current CallCenterAgent Voodoo powered
  • 35. // JSF UI Controller! @javax.enterprise.context.RequestScoped! @javax.inject.Named(“createCustomerController“)! public class CreateCustomerController {! ! // inject CustomerService and MailService via @Inject! ! @Inject @Current! private CallCenterAgent currentCallCenterAgent; ! ! private Customer customer; ! ! public String createCustomer() {! customer.setAuditInformation(currentCallCenterAgent);! customerService.create(customer); ! mailService.sendWelcomeMail(customer); ! return CUSTOMER_CREATED;! } ! ! // getter / setter for customer! ...! }! ! Migration Guide @Inject @Current CallCenterAgent Voodoo powered
  • 36. // JSF UI Controller! @javax.enterprise.context.RequestScoped! @javax.inject.Named(“createCustomerController“)! public class CreateCustomerController {! ! // inject CustomerService and MailService via @Inject! ! @Inject @Current! private CallCenterAgent currentCallCenterAgent; ! ! private Customer customer; ! ! public String createCustomer() {! customer.setAuditInformation(currentCallCenterAgent);! customerService.create(customer); ! mailService.sendWelcomeMail(customer); ! return CUSTOMER_CREATED;! } ! ! // getter / setter for customer! ...! }! ! Migration Guide @Inject @Current CallCenterAgent Voodoo powered
  • 37. // Customer Service EJB! @Stateless! public class CustomerService {! ! @Inject @Current! private CallCenterAgent currentCallCenterAgent; ! ! @PersistenceContext ! private EntityManager em; ! ! // transactional by default ! public void createCustomer(Customer customer) {! customer.setAuditInformation(currentCallCenterAgent); ! em.persist(customer);! } ! ! ...! }! ! Migration Guide @Inject @Current CallCenterAgent Voodoo powered
  • 38. Voodoo Steps: ! ‣ „Technology Independence“ ‣ „@Inject Business Objects“ ‣ „No more EJBs for Transactions only“ ‣ „No more pumped up Sessions“ ‣ „No more Infrastructure in Views“ ‣ „No more doAll( ) Business Methods“ Enterprise Architecture Migration Guide Voodoo powered
  • 39. Injizierbare CDI Ressourcen ! ‣ normale Java Klassen - optional mit @Named und/oder @Qualifier markiert ‣ EJBs - Stateless, Stateful, Singleton ‣ sonstige Java EE Resources - UserTransaction, PersistenceContext, ... No more EJBs Migration Guide Voodoo powered
  • 40. // Customer Service EJB ! @Stateless! public class CustomerService {! ! @Inject @Current! private CallCenterAgent currentCallCenterAgent; ! ! @PersistenceContext ! private EntityManager em; ! ! // transactional by default ! public void createCustomer(Customer customer) {! customer.setAuditInformation(currentCallCenterAgent); ! em.persist(customer);! } ! ! ...! }! ! Migration Guide No more EJBs Voodoo powered
  • 41. // Customer Service EJB - no annotation required!! @Stateless! public class CustomerService {! ! @Inject @Current! private CallCenterAgent currentCallCenterAgent; ! ! @PersistenceContext ! private EntityManager em; ! ! // transactional by default ! public void createCustomer(Customer customer) {! customer.setAuditInformation(currentCallCenterAgent); ! em.persist(customer);! } ! ! ...! }! ! Migration Guide Ok, aber wo bekommen wie die Transaktion jetzt her? No more EJBs Voodoo powered
  • 42. // Customer Service EJB - no annotation required!! @Stateless! public class CustomerService {! ! @Inject @Current! private CallCenterAgent currentCallCenterAgent; ! ! @PersistenceContext ! private EntityManager em; ! ! @Transactional ! public void createCustomer(Customer customer) {! customer.setAuditInformation(currentCallCenterAgent); ! em.persist(customer);! } ! ! ...! }! ! Migration Guide JTA 1.2 oder DeltaSpike oder als Self-Made CDI-Interceptor No more EJBs Voodoo powered
  • 43. ! @InterceptorBinding! @Target({TYPE, METHOD})! @Retention(RUNTIME)! public @interface Transactional {! ! @Nonbinding! public TransactionalType value() ! default TransactionalType.REQUIRED; ! ! }! ! Migration Guide No more EJBs Voodoo powered
  • 44. ! @Transactional ! @Interceptor! public class TransactionAdvice {! ! @Inject! private UserTransaction utx;! ! @AroundInvoke! public Object applyTransaction(! InvocationContext ic) throws Throwable {! ! ... // 1. implement utx.begin()! ic.proceed(); // 2. call original method! ... // 3. implement utx.commit()! ! } ! Migration Guide No more EJBs *XML registration omitted Voodoo powered
  • 45. // Customer Service - no annotation required!! public class CustomerService {! ! @Inject @Current! private CallCenterAgent currentCallCenterAgent; ! ! @PersistenceContext ! private EntityManager em; ! ! @Transactional ! public void createCustomer(Customer customer) {! customer.setAuditInformation(currentCallCenterAgent); ! em.persist(customer);! } ! ! ...! }! ! Migration Guide No more EJBs Voodoo powered
  • 46. Migration Guide UI Service Data JSF View UsecaseController Service Service EntityManager Entity TX No more EJBs Voodoo powered
  • 47. Migration Guide UI Service Data JSF View UsecaseController Service Service EntityManager Entity TX No more EJBs Voodoo powered
  • 48. // JSF UI Controller! @javax.enterprise.context.RequestScoped! @javax.inject.Named(“createCustomerController“)! public class CreateCustomerController {! ! @Inject! private CustomerService customerService;! ! private Customer customer; ! ! @Transactional! public String createCustomer() {! customerService.create(customer); ! ... // some additional use case “tx“ related work! return CUSTOMER_CREATED;! } ! ! // getter / setter for customer! ...! }! ! Migration Guide No more EJBs Voodoo powered
  • 49. Voodoo Steps: ! ‣ „Technology Independence“ ‣ „@Inject Business Objects“ ‣ „No more EJBs for Transactions only“ ‣ „No more pumped up Sessions“ ‣ „No more Infrastructure in Views“ ‣ „No more doAll( ) Business Methods“ Enterprise Architecture Migration Guide Voodoo powered
  • 50. Anti-Pattern „alles in die Session“ ! ‣ RequestScoped ist leider zu kurz ‣ ViewScoped irgendwie auch und „JSF only“ ‣ SessionScoped aus Mangel an Alternativen No more pumped up Session Migration Guide ‣ ViewScoped ab Java EE 7 auch als „CDI“ ‣ FlowScoped ab Java EE 7 Voodoo powered
  • 51. Migration Guide No more pumped up Session // JSF UI Controller! @javax.enterprise.context.SessionScoped! @javax.inject.Named(“deleteCustomerController“)! public class DeleteCustomerController implements Serializable {! ! // @EJB CustomerService, AuthenticationService and MailService! ! private Customer customerToDelete;! ! public String askForDeletion(Customer customer) {! customerToDelete = customer; ! return SHOW_DELETE_CONFIRMATION; ! } ! ! public String deleteCustomer(Customer customer) {! ... // call backend services! return CUSTOMER_DELETED; ! } ! ...! }! Voodoo powered
  • 52. Migration Guide No more pumped up Session // JSF UI Controller! @javax.context.enterprise.ConversationScoped! @javax.inject.Named(“deleteCustomerController“)! public class DeleteCustomerController implements Serializable {! ! private Customer customerToDelete;! ! @Inject! private Conversation conversation; ! ! public String askForDeletion(Customer customer) {! conversation.begin();! customerToDelete = customer; ! return SHOW_DELETE_CONFIRMATION; ! } ! ! public String deleteCustomer(Customer customer) {! conversation.end();! ... // call backend services! return CUSTOMER_DELETED; ! } ! ...! }! Was ist, wenn schon aktiv? Was ist, wenn nicht aktiv? Voodoo powered
  • 53. Voodoo Steps: ! ‣ „Technology Independence“ ‣ „@Inject Business Objects“ ‣ „No more EJBs for Transactions only“ ‣ „No more pumped up Sessions“ ‣ „No more Infrastructure in Views“ ‣ „No more doAll( ) Business Methods“ Enterprise Architecture Migration Guide Voodoo powered
  • 54. Views sind nach wie vor ein Problem ! ‣ Injection via U-EL ‣ Injection von UI Controllern No more Infrastructure in Views Migration Guide Voodoo powered
  • 55. Migration Guide <html ...>! <h:body>! <h:form>! ! Vorname: <h:inputText ! value=“#{createCustomerController.customer.firstname}"/>! Name: <h:inputText ! value=“#{createCustomerController.customer.lastname}"/> ! ! ! </h:form>! </h:body>! </html>! No more Infrastructure in Views Infrastruktur in derView Voodoo powered
  • 56. Migration Guide <html ...>! <h:body>! <h:form>! ! Vorname: <h:inputText ! value=“#{customerToCreate.firstname}"/>! Name: <h:inputText ! value=“#{customerToCreate.lastname}"/> ! ! ! </h:form>! </h:body>! </html>! No more Infrastructure in Views Fachlichkeit in derView Voodoo powered
  • 57. // JSF UI Controller! @javax.enterprise.context.RequestScoped! @javax.inject.Named(“createCustomerController“)! public class CreateCustomerController {! ! @Inject! private CustomerService customerService;! ! private Customer customer; ! ! // getter for customer! @javax.inject.Produces! @javax.inject.Named(“customerToCreate“) ! public Customer getCustomer {! return customer; ! }! ...! }! ! Migration Guide No more Infrastructure in Views Voodoo powered
  • 58. Voodoo Steps: ! ‣ „Technology Independence“ ‣ @Inject Business Objects ‣ „No more EJBs for Transactions only“ ‣ „No more pumped up Sessions“ ‣ „No more Infrastructure in Views“ ‣ „No more doAll( ) Business Methods“ Enterprise Architecture Migration Guide Voodoo powered
  • 59. Ein Use Case kommt selten allein ! ‣ Primärer Use Case - Create Customer ! ‣ Sekundärer Use Case - Send Welcome Mail ‣ Sekundärer Use Case - Für Mandant X ... ‣ Sekundärer Use Case - ... No more doAll() Business Methods Migration Guide Voodoo powered
  • 60. CDI Events zur losen Kopplung, d.h 
 Java EE Observer Patten inkl. ... ! ‣ Event Object & Event Producer ‣ Observer Method ! ‣ schichtenneutral für POJOs ‣ ggf. transaktionsgebunden ‣ synchrone Interaktion No more doAll() Business Methods Migration Guide Voodoo powered
  • 61. Migration Guide Event/Message 
 Producer CDI Bean Manager Observer Method Observer Method Observer Method No more doAll() Business Methods USER 
 CREATED interessant ok, danke gut zu wissen Voodoo powered
  • 62. OK, CDI Events - klingt super, aber ... ! ‣ Wie sieht ein solches Event aus? ‣ Und wie fange ich es ab? ! ‣ Und vor allem: Wie löse ich es aus? No more doAll() Business Methods Migration Guide Voodoo powered
  • 63. // JSF UI Controller! @javax.enterprise.context.RequestScoped! @javax.inject.Named(“createCustomerController“)! public class CreateCustomerController {! ! @Inject! private CustomerService customerService;! ! @Inject @Created! private Event<Customer> eventSource;! ! private Customer customer; ! ! @Transactional! public String createCustomer() {! customerService.create(customer); ! eventSource.fire(customer);! return CUSTOMER_CREATED;! } ! ...! }! Migration Guide No more doAll() Business Methods Voodoo powered
  • 64. Migration Guide @ApplicationScoped! public class MailService implements Serializable {! ! public void sendWelcomeMail(! @Observes! @Created Customer customer) { ! ! // do some work with the customer object! ! ...! }! ! ...! }! ‣ Wie fange ich es? No more doAll() Business Methods Wow! Geht da 
 noch mehr? Voodoo powered
  • 65. Migration Guide @ApplicationScoped! public class MailService implements Serializable {! ! public void sendWelcomeMail(! @Observes @TenantId(“4711“)! @Created Customer customer) { ! ! // do some work with the customer object for tenant 4711! ! ...! }! ! ...! }! ‣ Wie fange ich es? No more doAll() Business Methods Voodoo powered
  • 66. Migration Guide @ApplicationScoped! public class MailService implements Serializable {! ! // Conditional Observer Method that takes ! // - Transaction status, e.g. AFTER_SUCCESS, AFTER_FAILURE! // - Bean instance status, e.g. ALLWAYS! // into account! public void sendWelcomeMail(! @Observes( ! receive=ALLWAYS, // bean ! during=AFTER_SUCCESS // tx ! ) ! @Created Customer customer) { ! ... ! }! }! ! ‣ Conditional Observer No more doAll() Business Methods Voodoo powered
  • 67. Enterprise Architecture Voodoo Ansatz UI Domain JSF View UseCaseController Business Object Business Object Business Object TX Voodoo powered
  • 68. Enterprise Architecture Voodoo Ansatz UI Domain JSF View UseCaseController Business Object Business Object Business Object TX Voodoo powered
  • 69. New School Enterprise Architecture ! ‣ mit CDI ! ‣ typensicher ‣ schichtenneutral ‣ fachliche und technologische Injection ‣ eventgetriebene Entwicklung Fazit Enterprise Architecture Voodoo powered
  • 70. Voodoo
 Architecture
 @mobileLarson 
 @_openKnowledge Lars Röwekamp | CIO New Technologies

×