SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 

Kürzlich hochgeladen (20)

Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 

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