SlideShare une entreprise Scribd logo
1  sur  32
MyFaces CODI Scopes
Use the right scopes for your CDI beans
Agenda


•   The History
•   CODI in a Nutshell
•   CODI Setup
•   CODI Scopes in Action
•   Coding
•   CODI Conversation - Insights
•   Your Use-Cases
THE HISTORY
Scopes of the Servlet Spec

                         Application



                        Session




                  Custom Scopes




              Request
CODI Scope Overview

                           Application



                        Session



                      Window



               Conversation



             View-Access



            Request
Why custom Scopes?


• Request scope too short for most UI-Use-Cases
• Session scope
   – Too long
   – No support for multi-window applications
• Different (conversation) concepts available
   – MyFaces Orchestra
   – CDI Conversation Scope
   – MyFaces CODI Scopes
       • Conversation Scope
       • View-Access Scope
       • Window Scope
MyFaces Orchestra


•   CODI is NOT Orchestra.NEXT
•   Orchestra is for Spring (only)
•   CODI is for CDI (only)
•   Orchestra introduced great concepts!
     CODI was planned as "type-safe Orchestra" for CDI
    Now it’s way more (in most areas) but
    without Persistence-Management!
What‘s about @ConversationScoped of CDI?


• Completely broken for several use-cases!
• More like inflexible sessions per window
• Some of the disadvantages
   –   Overhead e.g. with failed conversion/validation
   –   Lazy termination (after the rendering process)
   –   Restarting conversations during a request isn’t possible
   –   End the whole conversation or nothing
   –   An explicit start is required
   –   Manual check if conversation has been started
• Test them with your use-cases!
   use them or forget them 
MyFaces CODI - Overview


• MyFaces Extensions CDI aka MyFaces CODI is a
  portable CDI extension which can be used with
  Apache OpenWebBeans, JBoss Weld,… and
  in combination with other portable CDI extensions
• CODI-Core is required in any case
• Modules
   –   JSF Module (for 1.2 and 2.0 and 2.1)
   –   JPA Module
   –   BV Module
   –   I18n-Message Module
   –   Scripting Module
   –   Test Support Modules
MyFaces CODI in a Nutshell



•   JSF 1.2 and 2.x          • Type-safe View-Configs
•   Type-safety              • Type-safe Navigation
•   Extensibility            • JPA Integration
•   Advanced Scopes          • Dependency Injection
•   Various Events             Support for BV
•   View-Controller          • Advanced I18n
•   JSF 2 Scope Mappings     • Scripting Integration
                             • And more!
CODI - SETUP
Getting CODI up and running


• Add CODI to the project
    – With Maven
        • Add the modules (or the all-in-one package) to the POM
    – Without Maven
        • Download the current dist package
        • Add the modules (or the all-in-one package) to the Classpath of
          the project
•   Start using it!



                      Hint:
                      mvn archetype:generate -DarchetypeCatalog=http://myfaces.apache.org
Getting CODI up and running - Hints


• With JEE 5 and Mojarra use the controlled bootstrapping
  add-on
• Attention (hint for all bean archives):
  Ensure that the libs aren’t duplicated – otherwise the CDI
  implementation will blame ambiguous interceptors, beans,…
CODI SCOPES IN ACTION
CODI Scopes (with OWB) - Performance
Request Scope (as a Comparison) - Details - 2
Request Scope (as a Comparison) - Details - 1
Window-Scope


•   Like an advanced session per Browser-Window/Tab
•   Use it e.g. instead of @SessionScoped
•   Starts automatically with the first access
•   No support for (CODI conversation-)groups
•   Example:

    @WindowScoped
    public class PreferencesBean
      implements Serializable {
      //...
    }
View-Access Scope


• The next page does not use a view-scoped bean
   the bean get un-scoped
• Simple alternative to @ConversationScoped (of CODI)
• Starts automatically with the first access
• No support for (CODI conversation-) groups
• Example

  @ViewAccessScoped
  public class RegistrationWizard
   implements Serializable {
    //...
  }
(Grouped) Conversations


• Every bean is isolated in a separated conversation
• The bean class is the implicit group
• Terminating a conversation un-scopes all beans connected
  with the conversation (per default 1) immediately
• Termination manually via API or automatically via timeout
• Starts automatically with the first access
• Example
  @ConversationScoped
  public class OrderWizard
   implements Serializable {
    //...
  }
Grouped Conversations - 1


• Grouping beans which belong to a logical conversation
  (e.g. a Use-Case) can be grouped together
• One bean can be used for multiple (parallel) use-cases
• @ConversationGroup is a "special" CDI qualifier
• Termination of the group  un-scoping of all bean(s)
• Example 1
  @ConversationScoped
  @ConversationGroup(OrderUseCase.class)
  public class Customer implements Serializable {
    //...
  }
Grouped Conversations - 2


@Produces
@ConversationScoped
@ConversationGroup(UseCase1.class)
public DemoBean createDemoBeanForUseCase1() {
  return new DemoBean("createDemoBeanForUseCase1");
}

@Produces
@ConversationScoped
@ConversationGroup(UseCase2.class)
public DemoBean createDemoBeanForUseCase2() {
  return new DemoBean("createDemoBeanForUseCase2");
}
Closing vs. Restarting Conversations - 1


• Conversation#close
  Closes a conversation immediately
• Conversation#restart
  Un-scopes all beans of the conversation but internal
  data-structures are intact for using it again
  (better performance)
• Example

   @Inject
   private Conversation conversation;
   //...
   this.conversation.close();
@CloseConversationGroup


• @CloseConversationGroup
  Interceptor for closing a conversation group e.g.
  after a method-invocation or based on a given exception.
• Examples:
   @CloseConversationGroup
   public void registerUser () {}

   @CloseConversationGroup(group = UseCase1.class)
   public void registerUser () {}

   @CloseConversationGroup(
     group = UseCase1.class, on = MyException.class)
   public void registerUser () {}
CODI CONVERSATION - INSIGHTS
Optional Configuration


• CodiConfig
   – WindowContextConfig
      •   getWindowContextTimeoutInMinutes
      •   isUnknownWindowIdsAllowed
      •   getMaxWindowContextCount
      •   isCloseEmptyWindowContextsEnabled
      •   is*EventEnabled
      •   …
   – ConversationConfig
      • getConversationTimeoutInMinutes
      • is*EventEnabled
      • …
   – …
WindowScoped vs WindowContext


• The Window-Context represents the whole window including
  all scopes which are bound to it
• Window-scoped beans are just a part of the current window
• WindowContext API allows to manage the current window
• Example

  @Inject
  private WindowContext windowContext;
  //...
  this.windowContext.getId();
  this.windowContext.closeConversations();
Window-Context

                                   Window(-Context)
                                       API and SPI


    [Scope]            [Scope]             [Scope]          [Scope]    [Scope]

   Window            Conversation       Conversation        View-      View-
                        Group:            Group:            Access     Access
                        Bean1            UseCase1




                                                              Bean 3




                                                                         Bean 4
   Bean 1

            Bean 2




                          Bean 1




                                          Bean 1

                                                   Bean 2

                                       Attributes
Powerful SPI


•   WindowContextManagerFactory
•   WindowContextFactory
•   WindowContextQuotaHandler
•   WindowHandler
•   ConversationFactory
•   WindowContextManager
•   BeanEntryFactory
•   …
Optional Events


• WindowContextEvent
   – CreateWindowContextEvent
   – CloseWindowContextEvent
• ConversationEvent
   – StartConversationEvent
   – RestartConversationEvent
   – CloseConversationEvent
• BeanEvent
   – ScopeBeanEvent
   – AccessBeanEvent
   – UnscopeBeanEvent
TELL US YOUR USE-CASES!
Links


•   http://myfaces.apache.org/extensions/cdi/
•   https://cwiki.apache.org/confluence/display/EXTCDI/Index
•   https://svn.apache.org/repos/asf/myfaces/extensions/cdi/
•   http://twitter.com/MyFacesTeam
•   http://myfaces.apache.org/extensions/cdi/mail-lists.html
•   Recommended
    – http://openwebbeans.apache.org
    – http://code.google.com/a/apache-extras.org/p/
      myfaces-codi-addons/
    – http://os890.spaaze.com/myfaces-codi

Contenu connexe

Tendances

Maven for Dummies
Maven for DummiesMaven for Dummies
Maven for DummiesTomer Gabel
 
Polygot Java EE on the GraalVM
Polygot Java EE on the GraalVMPolygot Java EE on the GraalVM
Polygot Java EE on the GraalVMRyan Cuprak
 
Introduction tomaven
Introduction tomavenIntroduction tomaven
Introduction tomavenManav Prasad
 
Note - Apache Maven Intro
Note - Apache Maven IntroNote - Apache Maven Intro
Note - Apache Maven Introboyw165
 
Java build tool_comparison
Java build tool_comparisonJava build tool_comparison
Java build tool_comparisonManav Prasad
 
Intelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulIntelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulMert Çalışkan
 
OSGi in 5 minutes
OSGi in 5 minutesOSGi in 5 minutes
OSGi in 5 minutesSerge Huber
 
Spring - CDI Interop
Spring - CDI InteropSpring - CDI Interop
Spring - CDI InteropRay Ploski
 
Turn you Java EE Monoliths into Microservices with WildFly Swarm
Turn you Java EE Monoliths into Microservices with WildFly SwarmTurn you Java EE Monoliths into Microservices with WildFly Swarm
Turn you Java EE Monoliths into Microservices with WildFly SwarmDimitris Andreadis
 
Java(ee) mongo db applications in the cloud
Java(ee) mongo db applications in the cloud Java(ee) mongo db applications in the cloud
Java(ee) mongo db applications in the cloud Shekhar Gulati
 
Spring 4 on Java 8 by Juergen Hoeller
Spring 4 on Java 8 by Juergen HoellerSpring 4 on Java 8 by Juergen Hoeller
Spring 4 on Java 8 by Juergen HoellerZeroTurnaround
 
Learning Maven by Example
Learning Maven by ExampleLearning Maven by Example
Learning Maven by ExampleHsi-Kai Wang
 

Tendances (20)

Liferay maven sdk
Liferay maven sdkLiferay maven sdk
Liferay maven sdk
 
Maven for Dummies
Maven for DummiesMaven for Dummies
Maven for Dummies
 
Polygot Java EE on the GraalVM
Polygot Java EE on the GraalVMPolygot Java EE on the GraalVM
Polygot Java EE on the GraalVM
 
Introduction tomaven
Introduction tomavenIntroduction tomaven
Introduction tomaven
 
Note - Apache Maven Intro
Note - Apache Maven IntroNote - Apache Maven Intro
Note - Apache Maven Intro
 
Java build tool_comparison
Java build tool_comparisonJava build tool_comparison
Java build tool_comparison
 
Java EE 8
Java EE 8Java EE 8
Java EE 8
 
Intelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulIntelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest Istanbul
 
OSGi in 5 minutes
OSGi in 5 minutesOSGi in 5 minutes
OSGi in 5 minutes
 
Maven basic concept
Maven basic conceptMaven basic concept
Maven basic concept
 
Spring - CDI Interop
Spring - CDI InteropSpring - CDI Interop
Spring - CDI Interop
 
Maven ppt
Maven pptMaven ppt
Maven ppt
 
Turn you Java EE Monoliths into Microservices with WildFly Swarm
Turn you Java EE Monoliths into Microservices with WildFly SwarmTurn you Java EE Monoliths into Microservices with WildFly Swarm
Turn you Java EE Monoliths into Microservices with WildFly Swarm
 
Java(ee) mongo db applications in the cloud
Java(ee) mongo db applications in the cloud Java(ee) mongo db applications in the cloud
Java(ee) mongo db applications in the cloud
 
Intro To OSGi
Intro To OSGiIntro To OSGi
Intro To OSGi
 
Spring 4 on Java 8 by Juergen Hoeller
Spring 4 on Java 8 by Juergen HoellerSpring 4 on Java 8 by Juergen Hoeller
Spring 4 on Java 8 by Juergen Hoeller
 
OSGi Presentation
OSGi PresentationOSGi Presentation
OSGi Presentation
 
Learning Maven by Example
Learning Maven by ExampleLearning Maven by Example
Learning Maven by Example
 
Maven tutorial
Maven tutorialMaven tutorial
Maven tutorial
 
From JavaEE to AngularJS
From JavaEE to AngularJSFrom JavaEE to AngularJS
From JavaEE to AngularJS
 

Similaire à MyFaces CODI Conversations

CDI Best Practices with Real-Life Examples - TUT3287
CDI Best Practices with Real-Life Examples - TUT3287CDI Best Practices with Real-Life Examples - TUT3287
CDI Best Practices with Real-Life Examples - TUT3287Ahmad Gohar
 
Effectively using Open Source with conda
Effectively using Open Source with condaEffectively using Open Source with conda
Effectively using Open Source with condaTravis Oliphant
 
The future of enterprise dependency injection: Contexts & Dependency Injectio...
The future of enterprise dependency injection: Contexts & Dependency Injectio...The future of enterprise dependency injection: Contexts & Dependency Injectio...
The future of enterprise dependency injection: Contexts & Dependency Injectio...Paul Bakker
 
BP-7 Share Customization Best Practices
BP-7 Share Customization Best PracticesBP-7 Share Customization Best Practices
BP-7 Share Customization Best PracticesAlfresco Software
 
Survey of Container Build Tools
Survey of Container Build ToolsSurvey of Container Build Tools
Survey of Container Build ToolsMichael Ducy
 
Apache Maven - eXo TN presentation
Apache Maven - eXo TN presentationApache Maven - eXo TN presentation
Apache Maven - eXo TN presentationArnaud Héritier
 
Version Control and Continuous Integration
Version Control and Continuous IntegrationVersion Control and Continuous Integration
Version Control and Continuous IntegrationGeff Henderson Chang
 
Lorraine JUG (1st June, 2010) - Maven
Lorraine JUG (1st June, 2010) - MavenLorraine JUG (1st June, 2010) - Maven
Lorraine JUG (1st June, 2010) - MavenArnaud Héritier
 
Spring introduction
Spring introductionSpring introduction
Spring introductionLê Hảo
 
BP-9 Share Customization Best Practices
BP-9 Share Customization Best PracticesBP-9 Share Customization Best Practices
BP-9 Share Customization Best PracticesAlfresco Software
 
Monoliths are so 2001 – What you need is Modularity
Monoliths are so 2001 – What you need is ModularityMonoliths are so 2001 – What you need is Modularity
Monoliths are so 2001 – What you need is ModularityGraham Charters
 
Starting from scratch in 2017
Starting from scratch in 2017Starting from scratch in 2017
Starting from scratch in 2017Stefano Bonetta
 
How maven makes your development group look like a bunch of professionals.
How maven makes your development group look like a bunch of professionals.How maven makes your development group look like a bunch of professionals.
How maven makes your development group look like a bunch of professionals.Fazreil Amreen Abdul Jalil
 
Organizing Your PHP Projects (2010 ConFoo)
Organizing Your PHP Projects (2010 ConFoo)Organizing Your PHP Projects (2010 ConFoo)
Organizing Your PHP Projects (2010 ConFoo)Paul Jones
 
Cocoapods in action
Cocoapods in actionCocoapods in action
Cocoapods in actionHan Qin
 
Symfony Live San Francisco 2017 - Symfony @ OpenSky
Symfony Live San Francisco 2017 - Symfony @ OpenSkySymfony Live San Francisco 2017 - Symfony @ OpenSky
Symfony Live San Francisco 2017 - Symfony @ OpenSkyPablo Godel
 
August Webinar - Water Cooler Talks: A Look into a Developer's Workbench
August Webinar - Water Cooler Talks: A Look into a Developer's WorkbenchAugust Webinar - Water Cooler Talks: A Look into a Developer's Workbench
August Webinar - Water Cooler Talks: A Look into a Developer's WorkbenchHoward Greenberg
 
Organinzing Your PHP Projects (2010 Memphis PHP)
Organinzing Your PHP Projects (2010 Memphis PHP)Organinzing Your PHP Projects (2010 Memphis PHP)
Organinzing Your PHP Projects (2010 Memphis PHP)Paul Jones
 
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20Michael Lihs
 
Zend Framework 2, What's new, Confoo 2011
Zend Framework 2, What's new, Confoo 2011Zend Framework 2, What's new, Confoo 2011
Zend Framework 2, What's new, Confoo 2011Bachkoutou Toutou
 

Similaire à MyFaces CODI Conversations (20)

CDI Best Practices with Real-Life Examples - TUT3287
CDI Best Practices with Real-Life Examples - TUT3287CDI Best Practices with Real-Life Examples - TUT3287
CDI Best Practices with Real-Life Examples - TUT3287
 
Effectively using Open Source with conda
Effectively using Open Source with condaEffectively using Open Source with conda
Effectively using Open Source with conda
 
The future of enterprise dependency injection: Contexts & Dependency Injectio...
The future of enterprise dependency injection: Contexts & Dependency Injectio...The future of enterprise dependency injection: Contexts & Dependency Injectio...
The future of enterprise dependency injection: Contexts & Dependency Injectio...
 
BP-7 Share Customization Best Practices
BP-7 Share Customization Best PracticesBP-7 Share Customization Best Practices
BP-7 Share Customization Best Practices
 
Survey of Container Build Tools
Survey of Container Build ToolsSurvey of Container Build Tools
Survey of Container Build Tools
 
Apache Maven - eXo TN presentation
Apache Maven - eXo TN presentationApache Maven - eXo TN presentation
Apache Maven - eXo TN presentation
 
Version Control and Continuous Integration
Version Control and Continuous IntegrationVersion Control and Continuous Integration
Version Control and Continuous Integration
 
Lorraine JUG (1st June, 2010) - Maven
Lorraine JUG (1st June, 2010) - MavenLorraine JUG (1st June, 2010) - Maven
Lorraine JUG (1st June, 2010) - Maven
 
Spring introduction
Spring introductionSpring introduction
Spring introduction
 
BP-9 Share Customization Best Practices
BP-9 Share Customization Best PracticesBP-9 Share Customization Best Practices
BP-9 Share Customization Best Practices
 
Monoliths are so 2001 – What you need is Modularity
Monoliths are so 2001 – What you need is ModularityMonoliths are so 2001 – What you need is Modularity
Monoliths are so 2001 – What you need is Modularity
 
Starting from scratch in 2017
Starting from scratch in 2017Starting from scratch in 2017
Starting from scratch in 2017
 
How maven makes your development group look like a bunch of professionals.
How maven makes your development group look like a bunch of professionals.How maven makes your development group look like a bunch of professionals.
How maven makes your development group look like a bunch of professionals.
 
Organizing Your PHP Projects (2010 ConFoo)
Organizing Your PHP Projects (2010 ConFoo)Organizing Your PHP Projects (2010 ConFoo)
Organizing Your PHP Projects (2010 ConFoo)
 
Cocoapods in action
Cocoapods in actionCocoapods in action
Cocoapods in action
 
Symfony Live San Francisco 2017 - Symfony @ OpenSky
Symfony Live San Francisco 2017 - Symfony @ OpenSkySymfony Live San Francisco 2017 - Symfony @ OpenSky
Symfony Live San Francisco 2017 - Symfony @ OpenSky
 
August Webinar - Water Cooler Talks: A Look into a Developer's Workbench
August Webinar - Water Cooler Talks: A Look into a Developer's WorkbenchAugust Webinar - Water Cooler Talks: A Look into a Developer's Workbench
August Webinar - Water Cooler Talks: A Look into a Developer's Workbench
 
Organinzing Your PHP Projects (2010 Memphis PHP)
Organinzing Your PHP Projects (2010 Memphis PHP)Organinzing Your PHP Projects (2010 Memphis PHP)
Organinzing Your PHP Projects (2010 Memphis PHP)
 
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
 
Zend Framework 2, What's new, Confoo 2011
Zend Framework 2, What's new, Confoo 2011Zend Framework 2, What's new, Confoo 2011
Zend Framework 2, What's new, Confoo 2011
 

Plus de os890

Flexibilitaet mit CDI und Apache DeltaSpike
Flexibilitaet mit CDI und Apache DeltaSpikeFlexibilitaet mit CDI und Apache DeltaSpike
Flexibilitaet mit CDI und Apache DeltaSpikeos890
 
MyFaces Extensions Validator r4 news
MyFaces Extensions Validator r4 newsMyFaces Extensions Validator r4 news
MyFaces Extensions Validator r4 newsos890
 
MyFaces CODI v0.9.0 News
MyFaces CODI v0.9.0 NewsMyFaces CODI v0.9.0 News
MyFaces CODI v0.9.0 Newsos890
 
MyFaces Extensions Validator r3 News
MyFaces Extensions Validator r3 NewsMyFaces Extensions Validator r3 News
MyFaces Extensions Validator r3 Newsos890
 
Metadatenbasierte Validierung
Metadatenbasierte ValidierungMetadatenbasierte Validierung
Metadatenbasierte Validierungos890
 
MyFaces Extensions Validator 1.x.2 News
MyFaces Extensions Validator 1.x.2 NewsMyFaces Extensions Validator 1.x.2 News
MyFaces Extensions Validator 1.x.2 Newsos890
 
MyFaces Extensions Validator Part 1 of 3
MyFaces Extensions Validator Part 1 of 3MyFaces Extensions Validator Part 1 of 3
MyFaces Extensions Validator Part 1 of 3os890
 

Plus de os890 (7)

Flexibilitaet mit CDI und Apache DeltaSpike
Flexibilitaet mit CDI und Apache DeltaSpikeFlexibilitaet mit CDI und Apache DeltaSpike
Flexibilitaet mit CDI und Apache DeltaSpike
 
MyFaces Extensions Validator r4 news
MyFaces Extensions Validator r4 newsMyFaces Extensions Validator r4 news
MyFaces Extensions Validator r4 news
 
MyFaces CODI v0.9.0 News
MyFaces CODI v0.9.0 NewsMyFaces CODI v0.9.0 News
MyFaces CODI v0.9.0 News
 
MyFaces Extensions Validator r3 News
MyFaces Extensions Validator r3 NewsMyFaces Extensions Validator r3 News
MyFaces Extensions Validator r3 News
 
Metadatenbasierte Validierung
Metadatenbasierte ValidierungMetadatenbasierte Validierung
Metadatenbasierte Validierung
 
MyFaces Extensions Validator 1.x.2 News
MyFaces Extensions Validator 1.x.2 NewsMyFaces Extensions Validator 1.x.2 News
MyFaces Extensions Validator 1.x.2 News
 
MyFaces Extensions Validator Part 1 of 3
MyFaces Extensions Validator Part 1 of 3MyFaces Extensions Validator Part 1 of 3
MyFaces Extensions Validator Part 1 of 3
 

Dernier

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 

Dernier (20)

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 

MyFaces CODI Conversations

  • 1. MyFaces CODI Scopes Use the right scopes for your CDI beans
  • 2. Agenda • The History • CODI in a Nutshell • CODI Setup • CODI Scopes in Action • Coding • CODI Conversation - Insights • Your Use-Cases
  • 4. Scopes of the Servlet Spec Application Session Custom Scopes Request
  • 5. CODI Scope Overview Application Session Window Conversation View-Access Request
  • 6. Why custom Scopes? • Request scope too short for most UI-Use-Cases • Session scope – Too long – No support for multi-window applications • Different (conversation) concepts available – MyFaces Orchestra – CDI Conversation Scope – MyFaces CODI Scopes • Conversation Scope • View-Access Scope • Window Scope
  • 7. MyFaces Orchestra • CODI is NOT Orchestra.NEXT • Orchestra is for Spring (only) • CODI is for CDI (only) • Orchestra introduced great concepts!  CODI was planned as "type-safe Orchestra" for CDI Now it’s way more (in most areas) but without Persistence-Management!
  • 8. What‘s about @ConversationScoped of CDI? • Completely broken for several use-cases! • More like inflexible sessions per window • Some of the disadvantages – Overhead e.g. with failed conversion/validation – Lazy termination (after the rendering process) – Restarting conversations during a request isn’t possible – End the whole conversation or nothing – An explicit start is required – Manual check if conversation has been started • Test them with your use-cases!  use them or forget them 
  • 9. MyFaces CODI - Overview • MyFaces Extensions CDI aka MyFaces CODI is a portable CDI extension which can be used with Apache OpenWebBeans, JBoss Weld,… and in combination with other portable CDI extensions • CODI-Core is required in any case • Modules – JSF Module (for 1.2 and 2.0 and 2.1) – JPA Module – BV Module – I18n-Message Module – Scripting Module – Test Support Modules
  • 10. MyFaces CODI in a Nutshell • JSF 1.2 and 2.x • Type-safe View-Configs • Type-safety • Type-safe Navigation • Extensibility • JPA Integration • Advanced Scopes • Dependency Injection • Various Events Support for BV • View-Controller • Advanced I18n • JSF 2 Scope Mappings • Scripting Integration • And more!
  • 12. Getting CODI up and running • Add CODI to the project – With Maven • Add the modules (or the all-in-one package) to the POM – Without Maven • Download the current dist package • Add the modules (or the all-in-one package) to the Classpath of the project • Start using it! Hint: mvn archetype:generate -DarchetypeCatalog=http://myfaces.apache.org
  • 13. Getting CODI up and running - Hints • With JEE 5 and Mojarra use the controlled bootstrapping add-on • Attention (hint for all bean archives): Ensure that the libs aren’t duplicated – otherwise the CDI implementation will blame ambiguous interceptors, beans,…
  • 14. CODI SCOPES IN ACTION
  • 15. CODI Scopes (with OWB) - Performance
  • 16. Request Scope (as a Comparison) - Details - 2
  • 17. Request Scope (as a Comparison) - Details - 1
  • 18. Window-Scope • Like an advanced session per Browser-Window/Tab • Use it e.g. instead of @SessionScoped • Starts automatically with the first access • No support for (CODI conversation-)groups • Example: @WindowScoped public class PreferencesBean implements Serializable { //... }
  • 19. View-Access Scope • The next page does not use a view-scoped bean  the bean get un-scoped • Simple alternative to @ConversationScoped (of CODI) • Starts automatically with the first access • No support for (CODI conversation-) groups • Example @ViewAccessScoped public class RegistrationWizard implements Serializable { //... }
  • 20. (Grouped) Conversations • Every bean is isolated in a separated conversation • The bean class is the implicit group • Terminating a conversation un-scopes all beans connected with the conversation (per default 1) immediately • Termination manually via API or automatically via timeout • Starts automatically with the first access • Example @ConversationScoped public class OrderWizard implements Serializable { //... }
  • 21. Grouped Conversations - 1 • Grouping beans which belong to a logical conversation (e.g. a Use-Case) can be grouped together • One bean can be used for multiple (parallel) use-cases • @ConversationGroup is a "special" CDI qualifier • Termination of the group  un-scoping of all bean(s) • Example 1 @ConversationScoped @ConversationGroup(OrderUseCase.class) public class Customer implements Serializable { //... }
  • 22. Grouped Conversations - 2 @Produces @ConversationScoped @ConversationGroup(UseCase1.class) public DemoBean createDemoBeanForUseCase1() { return new DemoBean("createDemoBeanForUseCase1"); } @Produces @ConversationScoped @ConversationGroup(UseCase2.class) public DemoBean createDemoBeanForUseCase2() { return new DemoBean("createDemoBeanForUseCase2"); }
  • 23. Closing vs. Restarting Conversations - 1 • Conversation#close Closes a conversation immediately • Conversation#restart Un-scopes all beans of the conversation but internal data-structures are intact for using it again (better performance) • Example @Inject private Conversation conversation; //... this.conversation.close();
  • 24. @CloseConversationGroup • @CloseConversationGroup Interceptor for closing a conversation group e.g. after a method-invocation or based on a given exception. • Examples: @CloseConversationGroup public void registerUser () {} @CloseConversationGroup(group = UseCase1.class) public void registerUser () {} @CloseConversationGroup( group = UseCase1.class, on = MyException.class) public void registerUser () {}
  • 26. Optional Configuration • CodiConfig – WindowContextConfig • getWindowContextTimeoutInMinutes • isUnknownWindowIdsAllowed • getMaxWindowContextCount • isCloseEmptyWindowContextsEnabled • is*EventEnabled • … – ConversationConfig • getConversationTimeoutInMinutes • is*EventEnabled • … – …
  • 27. WindowScoped vs WindowContext • The Window-Context represents the whole window including all scopes which are bound to it • Window-scoped beans are just a part of the current window • WindowContext API allows to manage the current window • Example @Inject private WindowContext windowContext; //... this.windowContext.getId(); this.windowContext.closeConversations();
  • 28. Window-Context Window(-Context) API and SPI [Scope] [Scope] [Scope] [Scope] [Scope] Window Conversation Conversation View- View- Group: Group: Access Access Bean1 UseCase1 Bean 3 Bean 4 Bean 1 Bean 2 Bean 1 Bean 1 Bean 2 Attributes
  • 29. Powerful SPI • WindowContextManagerFactory • WindowContextFactory • WindowContextQuotaHandler • WindowHandler • ConversationFactory • WindowContextManager • BeanEntryFactory • …
  • 30. Optional Events • WindowContextEvent – CreateWindowContextEvent – CloseWindowContextEvent • ConversationEvent – StartConversationEvent – RestartConversationEvent – CloseConversationEvent • BeanEvent – ScopeBeanEvent – AccessBeanEvent – UnscopeBeanEvent
  • 31. TELL US YOUR USE-CASES!
  • 32. Links • http://myfaces.apache.org/extensions/cdi/ • https://cwiki.apache.org/confluence/display/EXTCDI/Index • https://svn.apache.org/repos/asf/myfaces/extensions/cdi/ • http://twitter.com/MyFacesTeam • http://myfaces.apache.org/extensions/cdi/mail-lists.html • Recommended – http://openwebbeans.apache.org – http://code.google.com/a/apache-extras.org/p/ myfaces-codi-addons/ – http://os890.spaaze.com/myfaces-codi