• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Reduce to the Max: Lightweight Java EE
 

Reduce to the Max: Lightweight Java EE

on

  • 424 views

Speaker: Lars Röwekamp ...

Speaker: Lars Röwekamp
JAX 2013
25.4.2013

Dank Java EE Web Profile, inkl. JSF 2 und CDI, lassen sich moderne Webanwendungen deutlich leichtgewichtiger und eleganter aufbauen als bisher. Die Session zeigt anhand eines Migrationsszenarios, wie in wenigen Schritten aus einer Old-School-JSF-Anwendung eine State of the Art JSF-und-CDI-Anwendung werden kann – positive Nebeneffekte wie schichtenneutrale Validierung inklusive.

Statistics

Views

Total Views
424
Views on SlideShare
396
Embed Views
28

Actions

Likes
3
Downloads
23
Comments
0

1 Embed 28

http://www.openknowledge.de 28

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Reduce to the Max: Lightweight Java EE Reduce to the Max: Lightweight Java EE Presentation Transcript

    • JavaReduce to the MaxLightway Enterprise JavaLars Röwekamp | open knowledge GmbH@mobileLarson@_openknowledge
    • „Weniger ist mehr!“„Java EE ermöglicht - dank EE WebProfile - extrem elegante undleichtgewichtige EnterpriseAnwendungen“Was sie mitnehmen sollten ...JSF& CDI Lightway Java EE
    • „Weniger ist mehr!“„Java EE ermöglicht - dank EE WebProfile - extrem elegante undleichtgewichtige EnterpriseAnwendungen“Was sie mitnehmen sollten ...JSF& CDI Lightway Java EE
    • Der KlassikerJSF& CDI Lightway Java EE
    • Der KlassikerJSF& CDI Lightway Java EETX
    • Der KlassikerJSF& CDI Lightway Java EE
    • Ok, wo liegtdas Problem?
    • Heterogene Lösungen
    • Der KlassikerJSF& CDI Lightway Java EE
    • Der KlassikerJSF& CDI Lightway Java EEeigene DI, Validierung, LifeCycleeigene DI, Validierung, LifeCycleeigene DI, Validierung, LifeCycle
    • TechnologydrivesBusiness
    • Der KlassikerJSF& CDI Lightway Java EETXUC: „User“ anzeigen/ändern
    • Der KlassikerJSF& CDI Lightway Java EETXEinen JSFManagedBeanController, bitte.Und für mich einen EJBService.Entity X mit ID Y,wenn möglich.UC: „User“ anzeigen/ändern
    • Der KlassikerJSF& CDI Lightway Java EETXEinen JSFManagedBeanController, bitte.Und für mich einen EJBService.Entity X mit ID Y,wenn möglich.Hey, ich will doch nur denCurrent User!
    • Der KlassikerJSF& CDI Lightway Java EE@ManagedBean(name=“userController“)@SessionScopedpublic class UserControllerMB implements Serializable {private User user; // plus getter and setter@ManagedProperty(value=“#{authenticationController}“)private authControllerMB AuthenticationController;@EJBprivate UserService userService@EJBprivate MailService mailService... // some more services neededpublic String create() { .. }public String askForDeleteConfirmation() { ... }public String deleteAfterConfirmation() { ... }}
    • Der KlassikerJSF& CDI Lightway Java EE@ManagedBean(name=“userController“)@SessionScopedpublic class UserControllerMB implements Serializable {private User user; // plus getter and setter@ManagedProperty(value=“#{authenticationController}“)private authControllerMB AuthenticationController;@EJBprivate UserService userService@EJBprivate MailService mailService... // some more services neededpublic String create() { .. }public String askForDeleteConfirmation() { ... }public String deleteAfterConfirmation() { ... }}Layer Solution
    • Der KlassikerJSF& CDI Lightway Java EE@ManagedBean(name=“userController“)@SessionScopedpublic class UserControllerMB implements Serializable {private User user; // plus getter and setter@ManagedProperty(value=“#{authenticationController}“)private authControllerMB AuthenticationController;@EJBprivate UserService userService@EJBprivate MailService mailService... // some more services neededpublic String create() { .. }public String askForDeleteConfirmation() { ... }public String deleteAfterConfirmation() { ... }}String basiertes IoCLayer Solution
    • Der KlassikerJSF& CDI Lightway Java EE@ManagedBean(name=“userController“)@SessionScopedpublic class UserControllerMB implements Serializable {private User user; // plus getter and setter@ManagedProperty(value=“#{authenticationController}“)private authControllerMB AuthenticationController;@EJBprivate UserService userService@EJBprivate MailService mailService... // some more services neededpublic String create() { .. }public String askForDeleteConfirmation() { ... }public String deleteAfterConfirmation() { ... }}String basiertes IoCInfrastrutur InjectionLayer Solution
    • Der KlassikerJSF& CDI Lightway Java EE@ManagedBean(name=“userController“)@SessionScopedpublic class UserControllerMB implements Serializable {private User user; // plus getter and setter@ManagedProperty(value=“#{authenticationController}“)private authControllerMB AuthenticationController;@EJBprivate UserService userService@EJBprivate MailService mailService... // some more services neededpublic String create() { .. }public String askForDeleteConfirmation() { ... }public String deleteAfterConfirmation() { ... }}String basiertes IoCInfrastrutur InjectionTechnology InjectionLayer Solution
    • Der KlassikerJSF& CDI Lightway Java EE@ManagedBean(name=“userController“)@SessionScopedpublic class UserControllerMB implements Serializable {private User user; // plus getter and setter@ManagedProperty(value=“#{authenticationController}“)private authControllerMB AuthenticationController;@EJBprivate UserService userService@EJBprivate MailService mailService... // some more services neededpublic String create() { .. }public String askForDeleteConfirmation() { ... }public String deleteAfterConfirmation() { ... }}String basiertes IoCInfrastrutur InjectionString basierte NaviTechnology InjectionLayer Solution
    • Der KlassikerJSF& CDI Lightway Java EE@ManagedBean(name=“userController“)@SessionScopedpublic class UserControllerMB implements Serializable {...public String create() {if (user.getUsername() == user.getPassword()) {... // create faces messagesreturn USERNAME_SHOULD_NOT_EQUAL_PASSSWORD; // createUser.xhtml} else if (userService.checkForFreeUsername(user.getUsername())) {userService.create(user);mailService.sendWelcomeMail(user);SystemUser loggedInUser = authenticationController.getLoggedInUser();if (Role.ROLE_TRAINEE.equals(loggedInUser.getRole()) {trackingService.trackAction(TrackAction.USER_CREATED, user);}return “USER_CREATED“; // or userOverview.xhtml} else {... // create faces messagesreturn “DUPLICATE_USERNAME“; // or createUser.xhtml}}}
    • Der KlassikerJSF& CDI Lightway Java EE@ManagedBean(name=“userController“)@SessionScopedpublic class UserControllerMB implements Serializable {...public String create() {if (user.getUsername() == user.getPassword()) {... // create faces messagesreturn USERNAME_SHOULD_NOT_EQUAL_PASSSWORD; // createUser.xhtml} else if (userService.checkForFreeUsername(user.getUsername())) {userService.create(user);mailService.sendWelcomeMail(user);SystemUser loggedInUser = authenticationController.getLoggedInUser();if (Role.ROLE_TRAINEE.equals(loggedInUser.getRole()) {trackingService.trackAction(TrackAction.USER_CREATED, user);}return “USER_CREATED“; // or userOverview.xhtml} else {... // create faces messagesreturn “DUPLICATE_USERNAME“; // or createUser.xhtml}}}Monster UseCase
    • Der KlassikerJSF& CDI Lightway Java EE@ManagedBean(name=“userController“)@SessionScopedpublic class UserControllerMB implements Serializable {...public String create() {if (user.getUsername() == user.getPassword()) {... // create faces messagesreturn USERNAME_SHOULD_NOT_EQUAL_PASSSWORD; // createUser.xhtml} else if (userService.checkForFreeUsername(user.getUsername())) {userService.create(user);mailService.sendWelcomeMail(user);SystemUser loggedInUser = authenticationController.getLoggedInUser();if (Role.ROLE_TRAINEE.equals(loggedInUser.getRole()) {trackingService.trackAction(TrackAction.USER_CREATED, user);}return “USER_CREATED“; // or userOverview.xhtml} else {... // create faces messagesreturn “DUPLICATE_USERNAME“; // or createUser.xhtml}}}Monster UseCaseCross Validation
    • Der KlassikerJSF& CDI Lightway Java EE@ManagedBean(name=“userController“)@SessionScopedpublic class UserControllerMB implements Serializable{private User user;...public String askForDeleteConfirmation(User userToDelete) {user = userToDelete;return “USER_READY_FOR_DELETE“; // userDeleteConfirmation.xhtml}public String deleteAfterConfirmation() {userService.delete(user);... // do some more stuff, e.g. sending an email, tracking, ...user = null;return “USER_DELETED“; // userSuccessfulDeleted.xhtml}}
    • Der KlassikerJSF& CDI Lightway Java EE@ManagedBean(name=“userController“)@SessionScopedpublic class UserControllerMB implements Serializable{private User user;...public String askForDeleteConfirmation(User userToDelete) {user = userToDelete;return “USER_READY_FOR_DELETE“; // userDeleteConfirmation.xhtml}public String deleteAfterConfirmation() {userService.delete(user);... // do some more stuff, e.g. sending an email, tracking, ...user = null;return “USER_DELETED“; // userSuccessfulDeleted.xhtml}}Session statt „Wizard“Scope Mismatch
    • Java
    • JavaU are here!
    • Java„We want a typesafeand modern lightwayEnterprise Achritecture.“Refactoringis needed
    • Der Klassiker - revistedJSF& CDI Lightway Java EE
    • Der Klassiker - revistedJSF& CDI Lightway Java EE
    • Der Klassiker - revistedJSF& CDI Lightway Java EE
    • Java„Get ride of all theJSF specific ManagedBeans and Scopes.“RefactoringStep 1
    • Refactoring - Step 1JSF& CDI Lightway Java EE@javax.faces.bean.ManagedBean(name=“userController“)@javax.faces.bean.SessionScopedpublic class UserControllerMB implements Serializable {private User user; // plus getter and setter@javax.faces.ManagedProperty(value=“#{authenticationController}“)private authControllerMB AuthenticationController;@EJBprivate UserService userService@EJBprivate MailService mailService...}
    • Refactoring - Step 1JSF& CDI Lightway Java EE@javax.inject.Named(“userController“)@javax.enterprise.context.SessionScopedpublic class UserControllerMB implements Serializable {private User user; // plus getter and setter@javax.inject.Injectprivate authControllerMB AuthenticationController;@EJBprivate UserService userService@EJBprivate MailService mailService...}
    • Refactoring - Step 1JSF& CDI Lightway Java EE@javax.inject.Named(“userController“)@javax.enterprise.context.SessionScopedpublic class UserControllerMB implements Serializable {private User user; // plus getter and setter@javax.inject.Injectprivate authControllerMB AuthenticationController;@javax.inject.Injectprivate UserService userService@javax.inject.Injectprivate MailService mailService...}
    • Refactoring - Step 1JSF& CDI Lightway Java EE@SessionScopedclass MyBeanAProxy forclass MyModel@Inject@RequestScopedclass MyModelInjection Target Contextual Reference Contextual InstancebusinessMethod()Lookup or createreturnbusinessMethod()returnreturnSpezialfall
    • Java„Use BusinessInjection instead ofInfrastructure Injection.“RefactoringStep 2
    • Refactoring - Step 2JSF& CDI Lightway Java EE@Named(“userController“)@SessionScopedpublic class UserControllerMB implements Serializable {@Injectprivate AuthControllerMB authenticationController;@EJBprivate UserService userService@EJBprivate MailService mailService...}
    • Refactoring - Step 2JSF& CDI Lightway Java EE@Named(“userController“)@SessionScopedpublic class UserControllerMB implements Serializable {@Injectprivate SystemUser loggedInUser;@EJBprivate UserService userService@EJBprivate MailService mailService...}
    • Refactoring - Step 2JSF& CDI Lightway Java EE@Named(“userController“)@SessionScopedpublic class UserControllerMB implements Serializable {@Injectprivate SystemUser loggedInUser;@EJBprivate UserService userService@EJBprivate MailService mailService...}@Current
    • Refactoring - Step 2JSF& CDI Lightway Java EE@SessionScopedpublic class AuthenticationControllerimplements Serializable {private SystemUser authenticatedUser;public String authenticate() {...}public SystemUser getAuthenticatedUser() {return authenticatedUser;}}
    • Refactoring - Step 2JSF& CDI Lightway Java EE@SessionScopedpublic class AuthenticationControllerimplements Serializable {private SystemUser authenticatedUser;public String authenticate() {...}public SystemUser getAuthenticatedUser() {return authenticatedUser;}}@Produces @Current
    • Refactoring - Step 2JSF& CDI Lightway Java EE@SessionScopedpublic class AuthenticationControllerimplements Serializable {private SystemUser authenticatedUser;public String authenticate() {...}public SystemUser getAuthenticatedUser() {return authenticatedUser;}}@Produces @Current@Inject @Current SystemUser
    • Refactoring - Step 2JSF& CDI Lightway Java EE@SessionScopedpublic class AuthenticationControllerimplements Serializable {private SystemUser authenticatedUser;public String authenticate() {...}public SystemUser getAuthenticatedUser() {return authenticatedUser;}}@Produces @Current@Inject @Current SystemUser@Named(“loggedInUser“)#{loggedInUser}
    • Refactoring - Step 2JSF& CDI Lightway Java EE@SessionScopedpublic class AuthenticationControllerimplements Serializable {private SystemUser authenticatedUser;public String authenticate() {...}public SystemUser getAuthenticatedUser() {return authenticatedUser;}}@Produces @Current@Inject @Current SystemUser@Named(“loggedInUser“)#{loggedInUser}@RequestScoped
    • Refactoring - Step 2JSF& CDI Lightway Java EE@Qualifier@Target({FIELD, PARAMETER, METHOD, TYPE})@Retention(RUNTIME)public @interface Current { }
    • Refactoring - Step 2JSF& CDI Lightway Java EE@Qualifier@Target({FIELD, PARAMETER, METHOD, TYPE})@Retention(RUNTIME)public @interface Current { }Self-made Qualifier
    • Java„Split MonsterUse Case into itslogical & modular Parts.“RefactoringStep 3
    • Refactoring - Step 3JSF& CDI Lightway Java EE@Named(“userController“)@SessionScopedpublic class UserControllerMB implements Serializable {...public String create() {if (user.getUsername() == user.getPassword()) {... // create faces messagesreturn USERNAME_SHOULD_NOT_EQUAL_PASSSWORD; // createUser.xhtml} else if (userService.checkForFreeUsername(user.getUsername())) {userService.create(user);mailService.sendWelcomeMail(user);User loggedInUser = authenticationController.getLoggedInUser();if (Role.ROLE_TRAINEE.equals(loggedInUser.getRole()) {trackingService.trackAction(TrackAction.USER_CREATED, user);}return “USER_CREATED“; // or userOverview.xhtml} else {... // create faces messagesreturn “DUPLICATE_USERNAME“; // or createUser.xhtml}}}
    • Refactoring - Step 3JSF& CDI Lightway Java EE@Named(“userController“)@SessionScopedpublic class UserControllerMB implements Serializable {...public String create() {if (user.getUsername() == user.getPassword()) {... // create faces messagesreturn USERNAME_SHOULD_NOT_EQUAL_PASSSWORD; // createUser.xhtml} else if (userService.checkForFreeUsername(user.getUsername())) {userService.create(user);mailService.sendWelcomeMail(user);User loggedInUser = authenticationController.getLoggedInUser();if (Role.ROLE_TRAINEE.equals(loggedInUser.getRole()) {trackingService.trackAction(TrackAction.USER_CREATED, user);}return “USER_CREATED“; // or userOverview.xhtml} else {... // create faces messagesreturn “DUPLICATE_USERNAME“; // or createUser.xhtml}}}
    • JSF& CDI Lightway Java EE@Named(“userController“)@SessionScopedpublic class UserController implements Serializable {...private User user;...public String create() {userService.create(user); // main use case...return “USER_CREATED“; // navigation}}Refactoring - Step 3
    • JSF& CDI Lightway Java EE@Named(“userController“)@SessionScopedpublic class UserController implements Serializable {@Inject @Created Event<User> userCreatedEventSource;private User user;...public String create() {userService.create(user); // main use caseuserCreatedEventSource.fire(user); // sub use casesreturn “USER_CREATED“; // navigation}}Refactoring - Step 3
    • JSF& CDI Lightway Java EE@Named(“userController“)@SessionScopedpublic class UserController implements Serializable {@Inject @Created Event<User> userCreatedEventSource;private User user;...public String create() {userService.create(user); // main use caseuserCreatedEventSource.fire(user); // sub use casesreturn “USER_CREATED“; // navigation}}Refactoring - Step 3Loosly coupledvia CDI Event
    • JSF& CDI Lightway Java EE@ApplicationScopedpublic class MailService {public void sendWelcomeMail(@Observes@Created User createdUser) {... // do some work with createdUser}...}Refactoring - Step 3Event Consumer I
    • JSF& CDI Lightway Java EE@ApplicationScopedpublic class TrackingService {@Inject @Current User loggedInUser;public void trackUserCreated(@Observes@Created User newUser) {if (User.ROLE_TRAINEE.equals(loggedInUser.getRole()) {this.trackAction(TrackAction.USER_CREATED, newUser);}}...}Refactoring - Step 3Event Consumer II
    • JSF& CDI Lightway Java EE@ApplicationScopedpublic class TrackingService {@Inject @Current User loggedInUser;public void trackUserCreated(@Observes(during == AFTER_SUCCESS)@Created User newUser) {if (User.ROLE_TRAINEE.equals(loggedInUser.getRole()) {this.trackAction(TrackAction.USER_CREATED, newUser);}}...}Refactoring - Step 3Event Consumer II
    • JSF& CDI Lightway Java EE@ApplicationScopedpublic class GlobalCache {public void insertIntoCache(@Observes(receice == IF_EXISTS,during == AFTER_SUCCESS)@Created User newUser) {... // do some work}...public void deleteFromCache(@Observes(receice == IF_EXISTS,during == AFTER_SUCCESS)@Deleted User deletedUser) {... // do some other work}}Refactoring - Step 3Event Consumer II
    • Java„Validate onceand only once -not once per layer.“RefactoringStep 4
    • JSF& CDI Lightway Java EERefactoring - Step 4
    • JSF& CDI Lightway Java EERefactoring - Step 4
    • JSF& CDI Lightway Java EERefactoring - Step 4*many thanks to irian.at
    • JSF& CDI Lightway Java EERefactoring - Step 4*many thanks to irian.at
    • JSF& CDI Lightway Java EERefactoring - Step 4<html  xmlns=“http://www.w3.org/1999/xhtml”      ...      <h:form  id=“createUserForm”>            <h:outputLabel  for=“firstName“  value=“Vorname:“            <h:inputText  id=“firstName“                                        value=“#{userController.user.firstName}“>                  <f:validateRequired  />                  <f:validateLenght  minimum=“8“  />              </h:inputText>            ...                </h:form>      ...      <h:messages  globalOnly=“true”  /></html>
    • JSF& CDIUnd wo ist das Problem?‣ Cross Side Validation‣ Cross Layer Validation‣ Cross Component ValidationMigration GuideRefactoring - Step 4
    • JSF& CDICross Side/Layer Validation‣ Bean Validation 1.0 (JSR 303)‣ @nnotation basiert‣ Validierung des Domain Models‣ JSF 2 supported‣ eigene Constraints möglichMigration GuideRefactoring - Step 4
    • JSF& CDI Migration GuideRefactoring - Step 4public  class  User  {    @Birthday    private  Date  dateOfBirth;      @Min(value  =  0)    private  Integer  children;    @NotNull    private  String  firstName;          @NotNull    private  String  lastName;      ...}Validator Interface
    • JSF& CDICross Component Validation‣ JSF Events ermöglichen das gezielte Aufrufeneiner via <f:event> Tag angegebenen Methodeals direkte Reaktion auf ein Component Event‣ JSF Events sind u.a.‣ preValidate‣ postValidateMigration GuideRefactoring - Step 4
    • JSF& CDI Lightway Java EERefactoring - Step 4<html  xmlns=“http://www.w3.org/1999/xhtml”      ...      <h:form  id=“changePassword”>            <f:event  type=“postValidate”                              listener=“changePasswordBean.validate”  />            ...                </h:form>      ...      <h:messages  globalOnly=“true”  /></html>
    • JSF& CDI Lightway Java EERefactoring - Step 4public  class  ChangePasswordBean  {      ...    public  void  validate(ComonentSystemEvent  event)  {        UIForm  form  =  (UIForm)e.getComponent();          UIInput  oldPwdInput  =  (UIInput)form.findComponent(“oldPwd”);        String  oldPwd  =  (String)oldPwdInput.value();          ...                if  (oldPwd.equals(newPwd))  {              //  1.  set  faces  error  messgage              //  2.  render  response              ...        }    }}
    • Java„Make Transactionswhere you want - notwhere Technology.“RefactoringStep 5
    • JSF& CDI Lightway Java EETXRefactoring - Step 5
    • JSF& CDI Lightway Java EETXRefactoring - Step 5
    • JSF& CDI Lightway Java EE@Named(“userController“)@SessionScopedpublic class UserController implements Serializable {...public String create() {userService.create(user); // main use caseuserCreatedEventSource.fire(user); // Created Eventreturn “USER_CREATED“; // Navigation}}Refactoring - Step 5
    • JSF& CDI Lightway Java EE@Named(“userController“)@SessionScopedpublic class UserController implements Serializable {...public String create() {userService.create(user); // main use caseuserCreatedEventSource.fire(user); // Created Eventreturn “USER_CREATED“; // Navigation}}Refactoring - Step 5Transactional Use Case
    • JSF& CDI Lightway Java EE@Named(“userController“)@SessionScopedpublic class UserController implements Serializable {...public String create() {userService.create(user); // main use caseuserCreatedEventSource.fire(user); // Created Eventreturn “USER_CREATED“; // Navigation}}Refactoring - Step 5Transactional Use Case* JTA 1.2 oder DeltaSpike oder Self-Made@Transactional
    • JSF& CDI Lightway Java EE@InterceptorBinding@Retention(RetentionPolicy.RUNTIME)@Target({ElementType.METHOD, ElementType.TYPE})public @interface Transactional {@NonBindingpublic TransactionalType value()! default TransactionalType.REQUIRED;}Refactoring - Step 5
    • JSF& CDI Lightway Java EE@InterceptorBinding@Retention(RetentionPolicy.RUNTIME)@Target({ElementType.METHOD, ElementType.TYPE})public @interface Transactional {@NonBindingpublic TransactionalType value()! default TransactionalType.REQUIRED;}Refactoring - Step 5Transactional Annotation
    • JSF& CDI Lightway Java EE@Transactional @Interceptorpublic class TransactionInterceptor {@Injectprivate UserTransaction utx;@AroundInvokepublic Object applyTransaction(InvocationContext ic)throws Throwable {... // implement utx.begin()ic.proceed(); // call original method... // implement utx.commit()}}Refactoring - Step 5* XML Konfiguration
    • JSF& CDI Lightway Java EE@Transactional @Interceptorpublic class TransactionInterceptor {@Injectprivate UserTransaction utx;@AroundInvokepublic Object applyTransaction(InvocationContext ic)throws Throwable {... // implement utx.begin()ic.proceed(); // call original method... // implement utx.commit()}}Refactoring - Step 5* XML KonfigurationTransactional Interceptor
    • Java„Use correspondingScopes - not too shortand not too long“RefactoringStep 6
    • Refactoring - Step 6JSF& CDI Lightway Java EE@Named(“userController“)@SessionScopedpublic class UserControllerMB implements Serializable {private User user;...public String askForDeleteConfirmation(User userToDelete) {user = userToDelete;return “USER_READY_FOR_DELETE“; // userDeleteConfirmation.xhtml}public String deleteAfterConfirmation() {userService.delete(user);... // do some more stuff, e.g. sending an email, tracking, ...user = null;return “USER_DELETED“; // userSuccessfulDeleted.xhtml}}
    • Refactoring - Step 6JSF& CDI Lightway Java EE@RequestScopedclass MyBeanA@ConversationSopedclass MyWizard@Inject Conversation conv;// inside „start“ Methodeconv.begin();// inside „end“ Methodeconv.end();@RequestScopedclass MyBeanB@Inject@Inject
    • Refactoring - Step 6JSF& CDI Lightway Java EE@Named(“userController“)@ConversationScopedpublic class UserControllerMB implements Serializable {private User user;@InjectConversation conversation;...public String askForDeleteConfirmation(User userToDelete) {conversation.begin();user = userToDelete;return “USER_READY_FOR_DELETE“; // userDeleteConfirmation.xhtml}public String deleteAfterConfirmation() {...}}
    • Refactoring - Step 6JSF& CDI Lightway Java EE@Named(“userController“)@ConversationScopedpublic class UserControllerMB implements Serializable{private User user;@InjectConversation conversation;...public String askForDeleteConfirmation(User userToDelete) { ... }public String deleteAfterConfirmation() {conversation.end();userService.delete(user);... // do some more stuff, e.g. sending an email, tracking, ...user = null;return “USER_DELETED“; // or userSuccessfulDeleted.xhtml}}
    • Java„The Spec iskind of slow when itcomes to evolution.“The MissingPieces
    • EE Web Profile - Missing PiecesJSF& CDI Lightway Java EEBessere ConversationenBuilt-in Transaktionenweitere Scopestypesafe Navigationund vieles mehr ...
    • EE Web Profile - Missing PiecesJSF& CDI Lightway Java EE
    • JSF& CDILightway Enterprise Java‣ mit CDI‣ typensicher‣ schichtenneutral‣ fachliche und technologische Injection‣ eventgetriebene EntwicklungFazitMigration Guide
    • JavaReduce to the MaxLightway Enterprise JavaLars Röwekamp | open knowledge GmbH@mobileLarson@_openknowledge