SlideShare a Scribd company logo
1 of 36
CDI @ Apache
OpenWebBeans and DeltaSpike
        Deep Dive
       Mark Struberg
      Gerhard Petracek
Agenda
●   CDI and its terms
●   Why OpenWebBeans?
●   Portable CDI Extensions
●   CDI by example with DeltaSpike
CDI is a ...
●   JCP specification started in ~2007
    Contexts and Dependency Injection for
    the Java EE platform (CDI) as JSR-299
●   component model designed for Java EE
    (can be used with Java SE)
CDI Features
●   Type-safe Dependency Injection
●   Interceptors
●   Decorators
●   Events
●   SPI for implementing "Portable Extensions"
●   Unified EL integration
What is Dependency Injection?
●   "Inversion Of Control" object creation
●   No more hardcoded dependencies when
    working with Interfaces
    MailService ms = new VerySpecialMailService();
●   Basically the old Factory Pattern
●   Hollywood Principle:
    "Don't call us, we call you!"
●   Macho Principle
    "Dude, gimme that bloody stuff!"
Singletons and Contexts
●   What is a 'Singleton'
●   "exactly one single instance
    in a well specified context"
Built-in CDI Scopes
●   NormalScoped with well defined lifecycle:
    – @ApplicationScoped
    – @SessionScoped
    – @RequestScoped
    – @ConversationScoped
●   'Pseudo Scope':
     – @Dependent
Terms - Managed Bean
●   ... a Java Class and all it's rules to create
    (contextual) instances of that bean.
●   'Managed Beans' in JSR-299 and JSR-346
    doesn't mean JavaBeans!
●   Interface

    Bean<T> extends Contextual<T>
Terms - Contextual Instance
●   ... a Java instance created with the rules of
    the Managed Bean Bean<T>
●   Contextual Instances usually don't get
    injected directly!
Terms - Contextual Reference
●   ... a proxy for a Contextual Instance.
●   Proxies will automatically be created for
    injecting @NormalScope beans and allow
    decoupled scope handling
Bootstrapping & Runtime
●   Creating the meta information at startup
    –   Bean meta-data can be changed
    –   Fail fast (e.g. AmbiguousResolutionException)
●   Contextual Instance creation at runtime
    –   based on the Managed Beans
    –   the Context will maintain the instances
●   Well defined contextual instance
    termination
Why Apache OpenWebBeans?
●   Fast
●   Stable
●   Modular Plugin Architecture
●   Usable
    (e.g. alternative approach for BDAs)
Portable CDI Extensions
●   Apache MyFaces CODI
    http://myfaces.apache.org/extensions/cdi
●   JBoss Seam3
    http://seamframework.org/Seam3
●   Apache DeltaSpike
    http://incubator.apache.org/deltaspike
DeltaSpike closes the gaps
between ...
●   ... Java-EE and the needs of
        real-world applications
●   ... different CDI communities
History of Apache DeltaSpike
CDI in Action with Apache DeltaSpike
DeltaSpike 0.3 - Overview
●   Core
●   JPA
●   Security
●   Container-Control
Interceptors and Producers in action
@Transactional - 1
●   Transactional bean in the application

    @Transactional
    public class MyBean {
      @Inject
      private EntityManager em;
    }
@Transactional - 2
●   Producer and disposer in the application

    @Produces
    @TransactionScoped
    protected EntityManager defaultEntityManager() {
      return …;
    }

    protected void dispose(@Disposes EntityManager em) {
      if (em.isOpen()) {
         em.close();
      }
    }
@Transactional - 3
●   Interceptor annotation in DeltaSpike

    @InterceptorBinding
    public @interface Transactional {
      //...
    }
@Transactional - 4
●   Interceptor implementation in DeltaSpike

    @Interceptor @Transactional
    public class TransactionalInterceptor implements Serializable {

        @Inject private TransactionStrategy ts;

        @AroundInvoke
        public Object executeInTransaction(
          InvocationContext invocationContext)
          throws Exception {
            return ts.execute(invocationContext);
        }
    }
                                                    + config in the beans.xml
Qualifiers in action
@Transactional - 5
●   Transactional bean in the application

    @Transactional
    public class MyBean {
      @Inject
      private @First EntityManager em1;

        @Inject
        private @Second EntityManager em2;
    }
@Transactional - 6
●   Producer implementations in the application

    @Produces @RequestScoped @First
    protected EntityManager firstEntityManager() {
      //...
    }

    @Produces @RequestScoped @Second
    protected EntityManager secondEntityManager() {
      //...
    }
@Transactional - 7
●   Producers and disposers in the application

    protected void disposeFirst(@Disposes @First
      EntityManager em) {
        if (em.isOpen()) {
           em.close();
        }
    }
    protected void disposeSecond(@Disposes @Second
      EntityManager em) {
        if (em.isOpen()) {
           em.close();
      }
    }
@Transactional - 8
●   Qualifier implementations in the application
    @Qualifier
    public @interface First {
    }

    @Qualifier
    public @interface Second {
    }
Events in action
@BeforeJsfRequest - 1
●   Observer in the application

    public void onBeforeJsfRequest(
      @Observes @BeforeJsfRequest
      FacesContext facesContext) {
       //…
    }
@BeforeJsfRequest - 2
●   Fired event in DeltaSpike

    @Inject
    @BeforeJsfRequest
    private Event<FacesContext> beforeJsfRequestEvent;

    this.beforeJsfRequestEvent.fire(facesContext);
@Specializes and @Alternative
@Specializes configs - 1
●   Specialized type-safe config in the
    application

    @Specializes
    public class CustomWindowContextConfig
      extends WindowContextConfig {
        public int getWindowContextTimeoutInMinutes() {
           return 240;
        }
    }
@Specializes configs - 2
●   Config implementation in CODI (/DS)

    @ApplicationScoped
    public class WindowContextConfig {
      public int getWindowContextTimeoutInMinutes() {
        return 60;
      }
      public int getMaxWindowContextCount() {
        return 64;
      }
      //…
    }
@Alternative - 1
●   Alternative implementation in the
    application

    @Alternative
    @Exclude(
      exceptIfProjectStage = ProjectStage.Development.class)
    public class MockedMailService
      implements MailService {
    }




                                                  + config in beans.xml
@Alternative - 2
●   Primary implementation in the application

    public interface MailService {
    }

    @ApplicationScoped
    public class DefaultMailService
      implements MailService {
    }
Apache DeltaSpike.Next
●   Simple answer:
    There is no fixed master plan!
    The future depends on the community
    -> get involved!

More Related Content

What's hot

Spring - CDI Interop
Spring - CDI InteropSpring - CDI Interop
Spring - CDI InteropRay Ploski
 
Polygot Java EE on the GraalVM
Polygot Java EE on the GraalVMPolygot Java EE on the GraalVM
Polygot Java EE on the GraalVMRyan Cuprak
 
MyFaces Extensions Validator r3 News
MyFaces Extensions Validator r3 NewsMyFaces Extensions Validator r3 News
MyFaces Extensions Validator r3 Newsos890
 
Node.js Development with Apache NetBeans
Node.js Development with Apache NetBeansNode.js Development with Apache NetBeans
Node.js Development with Apache NetBeansRyan Cuprak
 
Faster Java EE Builds with Gradle
Faster Java EE Builds with GradleFaster Java EE Builds with Gradle
Faster Java EE Builds with GradleRyan Cuprak
 
Note - Apache Maven Intro
Note - Apache Maven IntroNote - Apache Maven Intro
Note - Apache Maven Introboyw165
 
Developing modern java web applications with java ee 7 and angular js
Developing modern java web applications with java ee 7 and angular jsDeveloping modern java web applications with java ee 7 and angular js
Developing modern java web applications with java ee 7 and angular jsShekhar Gulati
 
OSGi in 5 minutes
OSGi in 5 minutesOSGi in 5 minutes
OSGi in 5 minutesSerge Huber
 
Getting Started with Java EE 7
Getting Started with Java EE 7Getting Started with Java EE 7
Getting Started with Java EE 7Arun Gupta
 
OSGi and Java EE: A Hybrid Approach to Enterprise Java Application Development
OSGi and Java EE: A Hybrid Approach to Enterprise Java Application DevelopmentOSGi and Java EE: A Hybrid Approach to Enterprise Java Application Development
OSGi and Java EE: A Hybrid Approach to Enterprise Java Application DevelopmentSanjeeb Sahoo
 
Step by step guide to create theme for liferay dxp 7
Step by step guide to create theme for liferay dxp 7Step by step guide to create theme for liferay dxp 7
Step by step guide to create theme for liferay dxp 7Azilen Technologies Pvt. Ltd.
 
Open Services Gateway Initiative (OSGI)
Open Services Gateway Initiative (OSGI)Open Services Gateway Initiative (OSGI)
Open Services Gateway Initiative (OSGI)Peter R. Egli
 
Maven for Dummies
Maven for DummiesMaven for Dummies
Maven for DummiesTomer Gabel
 
Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)
Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)
Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)Robert Scholte
 

What's hot (20)

Spring - CDI Interop
Spring - CDI InteropSpring - CDI Interop
Spring - CDI Interop
 
Core java
Core javaCore java
Core java
 
Polygot Java EE on the GraalVM
Polygot Java EE on the GraalVMPolygot Java EE on the GraalVM
Polygot Java EE on the GraalVM
 
MyFaces Extensions Validator r3 News
MyFaces Extensions Validator r3 NewsMyFaces Extensions Validator r3 News
MyFaces Extensions Validator r3 News
 
Java EE 8
Java EE 8Java EE 8
Java EE 8
 
Node.js Development with Apache NetBeans
Node.js Development with Apache NetBeansNode.js Development with Apache NetBeans
Node.js Development with Apache NetBeans
 
Faster Java EE Builds with Gradle
Faster Java EE Builds with GradleFaster Java EE Builds with Gradle
Faster Java EE Builds with Gradle
 
Note - Apache Maven Intro
Note - Apache Maven IntroNote - Apache Maven Intro
Note - Apache Maven Intro
 
Developing modern java web applications with java ee 7 and angular js
Developing modern java web applications with java ee 7 and angular jsDeveloping modern java web applications with java ee 7 and angular js
Developing modern java web applications with java ee 7 and angular js
 
OSGi in 5 minutes
OSGi in 5 minutesOSGi in 5 minutes
OSGi in 5 minutes
 
Getting Started with Java EE 7
Getting Started with Java EE 7Getting Started with Java EE 7
Getting Started with Java EE 7
 
OSGi Presentation
OSGi PresentationOSGi Presentation
OSGi Presentation
 
OSGi and Java EE: A Hybrid Approach to Enterprise Java Application Development
OSGi and Java EE: A Hybrid Approach to Enterprise Java Application DevelopmentOSGi and Java EE: A Hybrid Approach to Enterprise Java Application Development
OSGi and Java EE: A Hybrid Approach to Enterprise Java Application Development
 
Step by step guide to create theme for liferay dxp 7
Step by step guide to create theme for liferay dxp 7Step by step guide to create theme for liferay dxp 7
Step by step guide to create theme for liferay dxp 7
 
Open Services Gateway Initiative (OSGI)
Open Services Gateway Initiative (OSGI)Open Services Gateway Initiative (OSGI)
Open Services Gateway Initiative (OSGI)
 
Java 9 preview
Java 9 previewJava 9 preview
Java 9 preview
 
Reactjs
ReactjsReactjs
Reactjs
 
Intro To OSGi
Intro To OSGiIntro To OSGi
Intro To OSGi
 
Maven for Dummies
Maven for DummiesMaven for Dummies
Maven for Dummies
 
Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)
Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)
Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)
 

Similar to OpenWebBeans and DeltaSpike at ApacheCon

Context and Dependency Injection 2.0
Context and Dependency Injection 2.0Context and Dependency Injection 2.0
Context and Dependency Injection 2.0Brian S. Paskin
 
J2EE vs JavaEE
J2EE vs JavaEEJ2EE vs JavaEE
J2EE vs JavaEEeanimou
 
Context and Dependency Injection
Context and Dependency InjectionContext and Dependency Injection
Context and Dependency InjectionWerner Keil
 
Android App Architecture with modern libs in practice. Our way in R.I.D., Ser...
Android App Architecture with modern libs in practice. Our way in R.I.D., Ser...Android App Architecture with modern libs in practice. Our way in R.I.D., Ser...
Android App Architecture with modern libs in practice. Our way in R.I.D., Ser...Sigma Software
 
DDD Framework for Java: JdonFramework
DDD Framework for Java: JdonFrameworkDDD Framework for Java: JdonFramework
DDD Framework for Java: JdonFrameworkbanq jdon
 
S314168 - What's New in Enterprise Java Bean Technology @ JavaOne Brazil 2010
S314168 - What's New in Enterprise Java Bean Technology @ JavaOne Brazil 2010S314168 - What's New in Enterprise Java Bean Technology @ JavaOne Brazil 2010
S314168 - What's New in Enterprise Java Bean Technology @ JavaOne Brazil 2010Arun Gupta
 
The new and smart way to build microservices - Eclipse MicroProfile
The new and smart way to build microservices - Eclipse MicroProfileThe new and smart way to build microservices - Eclipse MicroProfile
The new and smart way to build microservices - Eclipse MicroProfileEmily Jiang
 
Testable JavaScript: Application Architecture
Testable JavaScript:  Application ArchitectureTestable JavaScript:  Application Architecture
Testable JavaScript: Application ArchitectureMark Trostler
 
Cut your Dependencies with Dependency Injection for East Bay.NET User Group
Cut your Dependencies with Dependency Injection for East Bay.NET User Group Cut your Dependencies with Dependency Injection for East Bay.NET User Group
Cut your Dependencies with Dependency Injection for East Bay.NET User Group Theo Jungeblut
 
Ob1k presentation at Java.IL
Ob1k presentation at Java.ILOb1k presentation at Java.IL
Ob1k presentation at Java.ILEran Harel
 
Building resilient scheduling in distributed systems with Spring
Building resilient scheduling in distributed systems with SpringBuilding resilient scheduling in distributed systems with Spring
Building resilient scheduling in distributed systems with SpringMarek Jeszka
 
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?Whoops! Where did my architecture go?
Whoops! Where did my architecture go?Oliver Gierke
 
Dynamic Groovy Edges
Dynamic Groovy EdgesDynamic Groovy Edges
Dynamic Groovy EdgesJimmy Ray
 
Level Up Your Integration Testing With Testcontainers
Level Up Your Integration Testing With TestcontainersLevel Up Your Integration Testing With Testcontainers
Level Up Your Integration Testing With TestcontainersVMware Tanzu
 
Java EE Connector Architecture 1.6 (JSR 322) Technology
Java EE Connector Architecture 1.6 (JSR 322) TechnologyJava EE Connector Architecture 1.6 (JSR 322) Technology
Java EE Connector Architecture 1.6 (JSR 322) TechnologySivakumar Thyagarajan
 
谷歌 Scott-lessons learned in testability
谷歌 Scott-lessons learned in testability谷歌 Scott-lessons learned in testability
谷歌 Scott-lessons learned in testabilitydrewz lin
 
A Cocktail of Guice and Seam, the missing ingredients for Java EE 6
A Cocktail of Guice and Seam, the missing ingredients for Java EE 6A Cocktail of Guice and Seam, the missing ingredients for Java EE 6
A Cocktail of Guice and Seam, the missing ingredients for Java EE 6Saltmarch Media
 

Similar to OpenWebBeans and DeltaSpike at ApacheCon (20)

Context and Dependency Injection 2.0
Context and Dependency Injection 2.0Context and Dependency Injection 2.0
Context and Dependency Injection 2.0
 
Javaee6 Overview
Javaee6 OverviewJavaee6 Overview
Javaee6 Overview
 
J2EE vs JavaEE
J2EE vs JavaEEJ2EE vs JavaEE
J2EE vs JavaEE
 
Context and Dependency Injection
Context and Dependency InjectionContext and Dependency Injection
Context and Dependency Injection
 
Android App Architecture with modern libs in practice. Our way in R.I.D., Ser...
Android App Architecture with modern libs in practice. Our way in R.I.D., Ser...Android App Architecture with modern libs in practice. Our way in R.I.D., Ser...
Android App Architecture with modern libs in practice. Our way in R.I.D., Ser...
 
DDD Framework for Java: JdonFramework
DDD Framework for Java: JdonFrameworkDDD Framework for Java: JdonFramework
DDD Framework for Java: JdonFramework
 
Java Enterprise Edition
Java Enterprise EditionJava Enterprise Edition
Java Enterprise Edition
 
S314168 - What's New in Enterprise Java Bean Technology @ JavaOne Brazil 2010
S314168 - What's New in Enterprise Java Bean Technology @ JavaOne Brazil 2010S314168 - What's New in Enterprise Java Bean Technology @ JavaOne Brazil 2010
S314168 - What's New in Enterprise Java Bean Technology @ JavaOne Brazil 2010
 
The new and smart way to build microservices - Eclipse MicroProfile
The new and smart way to build microservices - Eclipse MicroProfileThe new and smart way to build microservices - Eclipse MicroProfile
The new and smart way to build microservices - Eclipse MicroProfile
 
Testable JavaScript: Application Architecture
Testable JavaScript:  Application ArchitectureTestable JavaScript:  Application Architecture
Testable JavaScript: Application Architecture
 
Cut your Dependencies with Dependency Injection for East Bay.NET User Group
Cut your Dependencies with Dependency Injection for East Bay.NET User Group Cut your Dependencies with Dependency Injection for East Bay.NET User Group
Cut your Dependencies with Dependency Injection for East Bay.NET User Group
 
Ob1k presentation at Java.IL
Ob1k presentation at Java.ILOb1k presentation at Java.IL
Ob1k presentation at Java.IL
 
Building resilient scheduling in distributed systems with Spring
Building resilient scheduling in distributed systems with SpringBuilding resilient scheduling in distributed systems with Spring
Building resilient scheduling in distributed systems with Spring
 
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
 
Dynamic Groovy Edges
Dynamic Groovy EdgesDynamic Groovy Edges
Dynamic Groovy Edges
 
Spring boot
Spring bootSpring boot
Spring boot
 
Level Up Your Integration Testing With Testcontainers
Level Up Your Integration Testing With TestcontainersLevel Up Your Integration Testing With Testcontainers
Level Up Your Integration Testing With Testcontainers
 
Java EE Connector Architecture 1.6 (JSR 322) Technology
Java EE Connector Architecture 1.6 (JSR 322) TechnologyJava EE Connector Architecture 1.6 (JSR 322) Technology
Java EE Connector Architecture 1.6 (JSR 322) Technology
 
谷歌 Scott-lessons learned in testability
谷歌 Scott-lessons learned in testability谷歌 Scott-lessons learned in testability
谷歌 Scott-lessons learned in testability
 
A Cocktail of Guice and Seam, the missing ingredients for Java EE 6
A Cocktail of Guice and Seam, the missing ingredients for Java EE 6A Cocktail of Guice and Seam, the missing ingredients for Java EE 6
A Cocktail of Guice and Seam, the missing ingredients for Java EE 6
 

Recently uploaded

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
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
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 

Recently uploaded (20)

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

OpenWebBeans and DeltaSpike at ApacheCon

  • 1. CDI @ Apache OpenWebBeans and DeltaSpike Deep Dive Mark Struberg Gerhard Petracek
  • 2. Agenda ● CDI and its terms ● Why OpenWebBeans? ● Portable CDI Extensions ● CDI by example with DeltaSpike
  • 3. CDI is a ... ● JCP specification started in ~2007 Contexts and Dependency Injection for the Java EE platform (CDI) as JSR-299 ● component model designed for Java EE (can be used with Java SE)
  • 4. CDI Features ● Type-safe Dependency Injection ● Interceptors ● Decorators ● Events ● SPI for implementing "Portable Extensions" ● Unified EL integration
  • 5. What is Dependency Injection? ● "Inversion Of Control" object creation ● No more hardcoded dependencies when working with Interfaces MailService ms = new VerySpecialMailService(); ● Basically the old Factory Pattern ● Hollywood Principle: "Don't call us, we call you!" ● Macho Principle "Dude, gimme that bloody stuff!"
  • 6. Singletons and Contexts ● What is a 'Singleton' ● "exactly one single instance in a well specified context"
  • 7. Built-in CDI Scopes ● NormalScoped with well defined lifecycle: – @ApplicationScoped – @SessionScoped – @RequestScoped – @ConversationScoped ● 'Pseudo Scope': – @Dependent
  • 8. Terms - Managed Bean ● ... a Java Class and all it's rules to create (contextual) instances of that bean. ● 'Managed Beans' in JSR-299 and JSR-346 doesn't mean JavaBeans! ● Interface Bean<T> extends Contextual<T>
  • 9. Terms - Contextual Instance ● ... a Java instance created with the rules of the Managed Bean Bean<T> ● Contextual Instances usually don't get injected directly!
  • 10. Terms - Contextual Reference ● ... a proxy for a Contextual Instance. ● Proxies will automatically be created for injecting @NormalScope beans and allow decoupled scope handling
  • 11. Bootstrapping & Runtime ● Creating the meta information at startup – Bean meta-data can be changed – Fail fast (e.g. AmbiguousResolutionException) ● Contextual Instance creation at runtime – based on the Managed Beans – the Context will maintain the instances ● Well defined contextual instance termination
  • 12. Why Apache OpenWebBeans? ● Fast ● Stable ● Modular Plugin Architecture ● Usable (e.g. alternative approach for BDAs)
  • 13. Portable CDI Extensions ● Apache MyFaces CODI http://myfaces.apache.org/extensions/cdi ● JBoss Seam3 http://seamframework.org/Seam3 ● Apache DeltaSpike http://incubator.apache.org/deltaspike
  • 14. DeltaSpike closes the gaps between ... ● ... Java-EE and the needs of real-world applications ● ... different CDI communities
  • 15. History of Apache DeltaSpike
  • 16. CDI in Action with Apache DeltaSpike
  • 17. DeltaSpike 0.3 - Overview ● Core ● JPA ● Security ● Container-Control
  • 19. @Transactional - 1 ● Transactional bean in the application @Transactional public class MyBean { @Inject private EntityManager em; }
  • 20. @Transactional - 2 ● Producer and disposer in the application @Produces @TransactionScoped protected EntityManager defaultEntityManager() { return …; } protected void dispose(@Disposes EntityManager em) { if (em.isOpen()) { em.close(); } }
  • 21. @Transactional - 3 ● Interceptor annotation in DeltaSpike @InterceptorBinding public @interface Transactional { //... }
  • 22. @Transactional - 4 ● Interceptor implementation in DeltaSpike @Interceptor @Transactional public class TransactionalInterceptor implements Serializable { @Inject private TransactionStrategy ts; @AroundInvoke public Object executeInTransaction( InvocationContext invocationContext) throws Exception { return ts.execute(invocationContext); } } + config in the beans.xml
  • 24. @Transactional - 5 ● Transactional bean in the application @Transactional public class MyBean { @Inject private @First EntityManager em1; @Inject private @Second EntityManager em2; }
  • 25. @Transactional - 6 ● Producer implementations in the application @Produces @RequestScoped @First protected EntityManager firstEntityManager() { //... } @Produces @RequestScoped @Second protected EntityManager secondEntityManager() { //... }
  • 26. @Transactional - 7 ● Producers and disposers in the application protected void disposeFirst(@Disposes @First EntityManager em) { if (em.isOpen()) { em.close(); } } protected void disposeSecond(@Disposes @Second EntityManager em) { if (em.isOpen()) { em.close(); } }
  • 27. @Transactional - 8 ● Qualifier implementations in the application @Qualifier public @interface First { } @Qualifier public @interface Second { }
  • 29. @BeforeJsfRequest - 1 ● Observer in the application public void onBeforeJsfRequest( @Observes @BeforeJsfRequest FacesContext facesContext) { //… }
  • 30. @BeforeJsfRequest - 2 ● Fired event in DeltaSpike @Inject @BeforeJsfRequest private Event<FacesContext> beforeJsfRequestEvent; this.beforeJsfRequestEvent.fire(facesContext);
  • 32. @Specializes configs - 1 ● Specialized type-safe config in the application @Specializes public class CustomWindowContextConfig extends WindowContextConfig { public int getWindowContextTimeoutInMinutes() { return 240; } }
  • 33. @Specializes configs - 2 ● Config implementation in CODI (/DS) @ApplicationScoped public class WindowContextConfig { public int getWindowContextTimeoutInMinutes() { return 60; } public int getMaxWindowContextCount() { return 64; } //… }
  • 34. @Alternative - 1 ● Alternative implementation in the application @Alternative @Exclude( exceptIfProjectStage = ProjectStage.Development.class) public class MockedMailService implements MailService { } + config in beans.xml
  • 35. @Alternative - 2 ● Primary implementation in the application public interface MailService { } @ApplicationScoped public class DefaultMailService implements MailService { }
  • 36. Apache DeltaSpike.Next ● Simple answer: There is no fixed master plan! The future depends on the community -> get involved!