SlideShare a Scribd company logo
1 of 56
Download to read offline
Is coming
CDI 2.0
@antoine_sd
@JosePaumard
@antoine_sd @JosePaumard#Devoxx #CDI2
Agenda
 Flashback on CDI 1.0, 1.1 and 1.2
 CDI 2.0 status
 Gathering feedback for CDI 2.0
 CDI 2.0 new features
 Questions and Feedback
Previously on CDI
CDI Timeline
Dec 2009 June 2013 Apr 2014 Sep 2014 2016
@antoine_sd @JosePaumard#Devoxx #CDI2
CDI 1.0 – December 2009
 A typesafe dependency injection mechanism
 A well-defined lifecycle for stateful objects
 The ability to decorate or to associate interceptors to
objects with a typesafe approach
 An event notification model
 An SPI allowing portable extensions
@antoine_sd @JosePaumard#Devoxx #CDI2
CDI 1.1 – June 2013
 CDI is automatically enabled in Java EE
 Introspection with bean, events, decorator and
interceptor metadata
 Ease access to CDI from non CDI code
 Work on interceptor for reuse by other Java EE specs
 SPI enhancement for portable extensions
@antoine_sd @JosePaumard#Devoxx #CDI2
CDI 1.2 – April 2014
 Clarifications in the spec
• Lifecycles
• Events
• Conversation scope
 Fix conflict with other JSR 330 frameworks
 OSGi support in the API
@antoine_sd @JosePaumard#Devoxx #CDI2
CDI 2.0 started 12 months ago
 JSR 365!
• First Java EE 8 JSR proposed and voted
 Weekly IRC meeting
 Regular release of Weld 3.0 Alpha (CDI 2.0 RI)
 We have a lot of community momentum
 Early Draft was released this summer
 Release expected in 2016 (Q2?)
@antoine_sd @JosePaumard#Devoxx #CDI2
EG members
 Pete Muir (Red Hat)
 Antoine Sabot-Durand (Red Hat)
 José Paumard
 John Ament
 David Currie (IBM)
 Anatole Tresch (Credit Suisse)
 Antonio Goncalves
 Thorben Janssen
 Raj. Hegde (JUG Chennai)
 Werner Keil
 Joseph Snyder (Oracle)
 Mark Paluch
 Florent Benoit (SERLI)
 Mark Struberg
 David Blevins (Tomitribe)
 George Gastaldi (Red Hat)
 Otavio Santana
@antoine_sd @JosePaumard#Devoxx #CDI2
We are open to the community!
@antoine_sd @JosePaumard#Devoxx #CDI2
Gathering
feedback for CDI
2.0
@antoine_sd @JosePaumard#Devoxx #CDI2
CDI 2.0 survey
260 participants
20 features to rate
@antoine_sd @JosePaumard#Devoxx #CDI2
1st feature
 Asynchronous support
for events and method invocation
@antoine_sd @JosePaumard#Devoxx #CDI2
Other top requested features
 @Startup for CDI
 Bootstraping outside of Java EE
 AOP for custom beans
 Security support
 Observers ordering, better event control
 Access to metadata through SPI
CDI 2.0 new features
Java SE support
Using CDI outside of the
Java EE Container
@antoine_sd @JosePaumard#Devoxx #CDI2
Why that?
 To ease the testing of CDI applications
 To provide a mean of building new stacks
out of Java EE
 To boost CDI adoption for Spec working
already on Java SE
 First step before working on a CDI light
@antoine_sd @JosePaumard#Devoxx #CDI2
Java SE support will start in EDR1
 We specified API to boot CDI in Java SE:
 Desktop and non Java EE application can now use a
standard way to boot CDI
public static void main(String... args) {
CDIProvider provider = CDI.getCDIProvider();
CDI<Object> cdi = provider.initialize();
// retrieve a bean and do work with it
MyBean myBean = cdi.select(MyBean.class).get();
myBean.doWork();
// when done
cdi.shutdown();
}
@antoine_sd @JosePaumard#Devoxx #CDI2
What did we do?
CDI Specification
CDI Core
CDI for Java
EE
CDI for Java
SE
@antoine_sd @JosePaumard#Devoxx #CDI2
There’s still work to do
 What about built-in contexts activation in Java SE?
• RequestScoped, SessionScoped,
ConversationScoped…
 Answer: we may introduce a new scope
• MethodScoped
• Living only during method invocation
• Activated by an Interceptor
• Discussion is in early stage on that
@antoine_sd @JosePaumard#Devoxx #CDI2
There’s still work to do
 What about bean discovery in Java SE?
• Annotated mode can be very costly
• Implicit bean archive is disable now
 Answer: we are working on SE enhancement
• Take more SE features from weld
• Choose bean discovery mode at build time
• Adding classes / packages explicitly at build time
Modularity
Provide sub specs in CDI (called parts)
that can be used independently
Each part should have an implementation
@antoine_sd @JosePaumard#Devoxx #CDI2
Why that?
 To avoid the “bloated spec” syndrom
 Having parts will help CDI adoption
 Third party won’t have to implement
the whole spec if they don’t want to
@antoine_sd @JosePaumard#Devoxx #CDI2
Full CDI
- Events
- Normal scopes
- Interceptor & Decorator
- Advanced SPI
Modularity – 2 core parts
CDI Light
- Basic DI
- Producers
- Programmatic lookup
- Singleton and dependent scopes
- Basic SPI for integration
@antoine_sd @JosePaumard#Devoxx #CDI2
Modularity – challenges
 Will bring 4 subspec:
• CDI light for Java SE
• CDI full for Java SE
• CDI light for Java EE
• CDI full for Java EE
 Having an RI and TCK for each part can be an
important work
Enhancing events
Making a popular feature
even more popular!
@antoine_sd @JosePaumard#Devoxx #CDI2
Enhancing Events
 CDI events are a very loved feature!
For CDI 2.0, we plan to introduce :
 Asynchronous events
 Events ordering
@antoine_sd @JosePaumard#Devoxx #CDI2
Events in CDI 1.x: patterns
 Firing pattern:
@Inject
Event<Payload> event;
public void someBSCriticalBusinessMethod() throws WTFException {
event.fire(new Payload());
}
@antoine_sd @JosePaumard#Devoxx #CDI2
Events in CDI 1.x: patterns
 Observing pattern:
 Supports qualifiers and many other things
public void callMe(@Observes Payload payload) {
// Do something with the event
}
@antoine_sd @JosePaumard#Devoxx #CDI2
CDI 1.x: Sync / Async
 Sync / Async is not specified
 The immutable status of the payload is not specified
 Implementations use a Sync model
 The payload is mutated in some implementations /
framework
 Going async “blindly” might raise problems…
@antoine_sd @JosePaumard#Devoxx #CDI2
Events are sync in CDI 1
Right now:
 All the observers are called in the firing thread
 In no particular order (at least not specified)
 The payload may be mutated
@antoine_sd @JosePaumard#Devoxx #CDI2
Events and contexts
Contexts
 Two contexts are critical: transactions and HTTP
requests / sessions
 Events are aware of those contexts
 In an all-sync world, everything is fine
 But in an async world, we will be in trouble
@antoine_sd @JosePaumard#Devoxx #CDI2
Asynchronous Events
 So designing backward compatible async events is more
tricky than it looks:
1) A currently sync event should remain sync
2) Going sync / async should be a decision taken
from the firing side
3) Being sync should be possible from the observing side
@antoine_sd @JosePaumard#Devoxx #CDI2
Asynchronous Events
 Pattern for the firing side:
@Inject
Event<Payload> event;
public void someEvenMoreCriticalBusinessMethod() {
event.fireAsync(new Payload());
}
@antoine_sd @JosePaumard#Devoxx #CDI2
Asynchronous Events
 Pattern for the observing side:
public void callMe(@Observes Payload payload) {
// I am called in the firing thread
// Whether is was async fired or not
}
public void callMe(@ObservesAsync Payload payload) {
// I am called in another thread
}
@antoine_sd @JosePaumard#Devoxx #CDI2
Asynchronous Events
 So, in a nutshell
callMe(
@Observes payload)
callMe(
@ObservesAsync payload)
event
.fire(payload) Sync call Not notified
event
.fireAsync(payload) Not notified Async call
@antoine_sd @JosePaumard#Devoxx #CDI2
What about mutable payloads?
 One short answer:
 Don’t do it!
 Or suffer the full penalty of race conditions!
@antoine_sd @JosePaumard#Devoxx #CDI2
We have some more
 Let us come back to this pattern:
 1st question: in what thread are the observers going to
be called?
@Inject
Event<Payload> event;
public void someOtherCriticalBusinessMethod() {
event.fireAsync(new Payload());
}
@antoine_sd @JosePaumard#Devoxx #CDI2
We have some more
 Let us come back to this pattern:
 2nd question: what if exceptions are thrown by the
observers?
@Inject
Event<Payload> event;
public void someOtherCriticalBusinessMethod() {
event.fireAsync(new Payload());
}
@antoine_sd @JosePaumard#Devoxx #CDI2
Adding an Executor to fireAsync
 What if the observer needs to be called in the GUI
thread?
@Inject
Event<PanelUpdater> event;
public void someOtherCriticalBusinessMethod() {
event.fireAsync(new PanelUpdater(green),
executor); // Of type Executor
}
@antoine_sd @JosePaumard#Devoxx #CDI2
Adding an Executor to fireAsync
 What if the observer needs to be called in the GUI
thread?
@Inject
Event<PanelUpdater> event;
public void someOtherCriticalBusinessMethod() {
event.fireAsync(new PanelUpdater(green),
SwingUtilities::invokeLater);
}
@antoine_sd @JosePaumard#Devoxx #CDI2
Handling exceptions
 The firing async is built on the Java 8 async model:
CompletionStage
@Inject
Event<PanelUpdater> event;
public void someOtherCriticalBusinessMethod() {
CompletionStage<PanelUpdater> stage =
event.fireAsync(new PanelUpdater(green),
SwingUtilities::invokeLater);
}
@antoine_sd @JosePaumard#Devoxx #CDI2
Handling exceptions
 Three ways of handling exceptions:
Returns a new CompletionStage
 That completes when the CS completes
 Either with the same result (normal completion)
 Or with the transformed exception
stage.exceptionaly( // Function
exception -> doSomethingNotTooStupidWith(exception));
@antoine_sd @JosePaumard#Devoxx #CDI2
Handling exceptions
 Three ways of handling exceptions:
Returns a new CompletionStage
 That completes when the CS completes
 Calls the BiFunction with a null as result or exception
 As a bonus: observers can return objects!
stage.handle( // BiFunction
(result, exception) -> doSomethingWith(result, exception));
@antoine_sd @JosePaumard#Devoxx #CDI2
Handling exceptions
 Three ways of handling exceptions:
 The returned exception is a FireAsyncException
 It holds all the exceptions in the
suppressed exception set
stage.handle( // BiFunction
(result, exception) -> doSomethingWith(result, exception));
@antoine_sd @JosePaumard#Devoxx #CDI2
Handling exceptions
 Three ways of handling exceptions:
stage.whenComplete( // BiConsumer, also async version
(result, exception) -> doSomethingWith(result, exception));
@antoine_sd @JosePaumard#Devoxx #CDI2
Events ordering
 Pattern:
 Ordering in async… possible but complex
public void firstObserver(@Observes @Priority(1) Payload p) {}
public void secondObserver(@Observes @Priority(2) Payload p) {}
AOP Enhancement
@antoine_sd @JosePaumard#Devoxx #CDI2
Support AOP on producer
 In CDI 1.x you cannot bind an interceptor to a produced
bean
 When you write:
 @Transactional is applied to producer method
@Produces
@Transactional
public MyService produceService() {
...
}
@antoine_sd @JosePaumard#Devoxx #CDI2
Support AOP on producer
 We are working on an instance builder.
 Inspired by the UnManaged class
 This builder could take an AnnotatedType to know
where adding interceptor bindings
@antoine_sd @JosePaumard#Devoxx #CDI2
BeanInstanceBuilder example
@Produces @RequestScoped
public MyClass produceTransactionalMyClass() {
BeanInstanceBuilder<MyClass> bib = new BeanInstanceBuilder<>();
AnnotatedTypeBuilder<MyClass> atb = new AnnotatedTypeBuilder<>()
.readFrom(MyClass.class)
.addToMethod(MyClass.class.getMethod("performInTransaction"),
new TransactionalLiteral());
return bib.readFromType(atb.build()).build();
}
CDI 2.0 DEMO
Which JSR
you’ll use
365 days a year?
JSR 365!!
@antoine_sd @JosePaumard#Devoxx #CDI2
CDI 2.0 needs you!!
CDI 2.0 specification is open to everyone
Mailing list, IRC channel
http://cdi-spec.org @cdispec

More Related Content

What's hot

New York Kubernetes: CI/CD Patterns for Kubernetes
New York Kubernetes: CI/CD Patterns for KubernetesNew York Kubernetes: CI/CD Patterns for Kubernetes
New York Kubernetes: CI/CD Patterns for KubernetesAndrew Phillips
 
Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014Antoine Sabot-Durand
 
OpenDDR and Jakarta MVC - JavaLand 2021
OpenDDR and Jakarta MVC - JavaLand 2021OpenDDR and Jakarta MVC - JavaLand 2021
OpenDDR and Jakarta MVC - JavaLand 2021Werner Keil
 
Scala on androids
Scala on androidsScala on androids
Scala on androidsthoraage
 
Steelcon 2015 Reverse-Engineering Obfuscated Android Applications
Steelcon 2015 Reverse-Engineering Obfuscated Android ApplicationsSteelcon 2015 Reverse-Engineering Obfuscated Android Applications
Steelcon 2015 Reverse-Engineering Obfuscated Android ApplicationsTom Keetch
 
Binary Authorization in Kubernetes
Binary Authorization in KubernetesBinary Authorization in Kubernetes
Binary Authorization in KubernetesAysylu Greenberg
 
Common primitives in Docker environments
Common primitives in Docker environmentsCommon primitives in Docker environments
Common primitives in Docker environmentsalexandru giurgiu
 
Test code that will not slow you down
Test code that will not slow you downTest code that will not slow you down
Test code that will not slow you downKostadin Golev
 
Software Supply Chain Management with Grafeas and Kritis
Software Supply Chain Management with Grafeas and KritisSoftware Supply Chain Management with Grafeas and Kritis
Software Supply Chain Management with Grafeas and KritisAysylu Greenberg
 
基於 Flow & Path 的 MVP 架構
基於 Flow & Path 的 MVP 架構基於 Flow & Path 的 MVP 架構
基於 Flow & Path 的 MVP 架構玄武 Wu
 
Android MvRx Framework 介紹
Android MvRx Framework 介紹Android MvRx Framework 介紹
Android MvRx Framework 介紹Kros Huang
 
Spring Up Your Graph
Spring Up Your GraphSpring Up Your Graph
Spring Up Your GraphVMware Tanzu
 
Trying to build an Open Source browser in 2020
Trying to build an Open Source browser in 2020Trying to build an Open Source browser in 2020
Trying to build an Open Source browser in 2020Patricia Aas
 
DevNexus 2019: MicroProfile and Jakarta EE - What's Next?
DevNexus 2019:  MicroProfile and Jakarta EE - What's Next?DevNexus 2019:  MicroProfile and Jakarta EE - What's Next?
DevNexus 2019: MicroProfile and Jakarta EE - What's Next?Kevin Sutter
 
Implementing Microservices with Jakarta EE and MicroProfile
Implementing Microservices with Jakarta EE and MicroProfileImplementing Microservices with Jakarta EE and MicroProfile
Implementing Microservices with Jakarta EE and MicroProfileKevin Sutter
 
OpenDaylight Developers Experience 1.5: Eclipse Setup, HOT reload, future plans
OpenDaylight Developers Experience 1.5: Eclipse Setup, HOT reload, future plansOpenDaylight Developers Experience 1.5: Eclipse Setup, HOT reload, future plans
OpenDaylight Developers Experience 1.5: Eclipse Setup, HOT reload, future plansMichael Vorburger
 
Android reverse engineering: understanding third-party applications. OWASP EU...
Android reverse engineering: understanding third-party applications. OWASP EU...Android reverse engineering: understanding third-party applications. OWASP EU...
Android reverse engineering: understanding third-party applications. OWASP EU...Internet Security Auditors
 
Peering Inside the Black Box: A Case for Observability
Peering Inside the Black Box: A Case for ObservabilityPeering Inside the Black Box: A Case for Observability
Peering Inside the Black Box: A Case for ObservabilityVMware Tanzu
 

What's hot (20)

CDI In Real Life
CDI In Real LifeCDI In Real Life
CDI In Real Life
 
New York Kubernetes: CI/CD Patterns for Kubernetes
New York Kubernetes: CI/CD Patterns for KubernetesNew York Kubernetes: CI/CD Patterns for Kubernetes
New York Kubernetes: CI/CD Patterns for Kubernetes
 
Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014
 
OpenDDR and Jakarta MVC - JavaLand 2021
OpenDDR and Jakarta MVC - JavaLand 2021OpenDDR and Jakarta MVC - JavaLand 2021
OpenDDR and Jakarta MVC - JavaLand 2021
 
Scala on androids
Scala on androidsScala on androids
Scala on androids
 
Steelcon 2015 Reverse-Engineering Obfuscated Android Applications
Steelcon 2015 Reverse-Engineering Obfuscated Android ApplicationsSteelcon 2015 Reverse-Engineering Obfuscated Android Applications
Steelcon 2015 Reverse-Engineering Obfuscated Android Applications
 
Binary Authorization in Kubernetes
Binary Authorization in KubernetesBinary Authorization in Kubernetes
Binary Authorization in Kubernetes
 
Common primitives in Docker environments
Common primitives in Docker environmentsCommon primitives in Docker environments
Common primitives in Docker environments
 
Test code that will not slow you down
Test code that will not slow you downTest code that will not slow you down
Test code that will not slow you down
 
Software Supply Chain Management with Grafeas and Kritis
Software Supply Chain Management with Grafeas and KritisSoftware Supply Chain Management with Grafeas and Kritis
Software Supply Chain Management with Grafeas and Kritis
 
基於 Flow & Path 的 MVP 架構
基於 Flow & Path 的 MVP 架構基於 Flow & Path 的 MVP 架構
基於 Flow & Path 的 MVP 架構
 
Android MvRx Framework 介紹
Android MvRx Framework 介紹Android MvRx Framework 介紹
Android MvRx Framework 介紹
 
Spring Up Your Graph
Spring Up Your GraphSpring Up Your Graph
Spring Up Your Graph
 
Trying to build an Open Source browser in 2020
Trying to build an Open Source browser in 2020Trying to build an Open Source browser in 2020
Trying to build an Open Source browser in 2020
 
DevNexus 2019: MicroProfile and Jakarta EE - What's Next?
DevNexus 2019:  MicroProfile and Jakarta EE - What's Next?DevNexus 2019:  MicroProfile and Jakarta EE - What's Next?
DevNexus 2019: MicroProfile and Jakarta EE - What's Next?
 
Implementing Microservices with Jakarta EE and MicroProfile
Implementing Microservices with Jakarta EE and MicroProfileImplementing Microservices with Jakarta EE and MicroProfile
Implementing Microservices with Jakarta EE and MicroProfile
 
OpenDaylight Developers Experience 1.5: Eclipse Setup, HOT reload, future plans
OpenDaylight Developers Experience 1.5: Eclipse Setup, HOT reload, future plansOpenDaylight Developers Experience 1.5: Eclipse Setup, HOT reload, future plans
OpenDaylight Developers Experience 1.5: Eclipse Setup, HOT reload, future plans
 
Android reverse engineering: understanding third-party applications. OWASP EU...
Android reverse engineering: understanding third-party applications. OWASP EU...Android reverse engineering: understanding third-party applications. OWASP EU...
Android reverse engineering: understanding third-party applications. OWASP EU...
 
Reverse Engineering Android Application
Reverse Engineering Android ApplicationReverse Engineering Android Application
Reverse Engineering Android Application
 
Peering Inside the Black Box: A Case for Observability
Peering Inside the Black Box: A Case for ObservabilityPeering Inside the Black Box: A Case for Observability
Peering Inside the Black Box: A Case for Observability
 

Viewers also liked

Invoke dynamite in Java EE with invoke dynamic
Invoke dynamite in Java EE with invoke dynamicInvoke dynamite in Java EE with invoke dynamic
Invoke dynamite in Java EE with invoke dynamicAntoine Sabot-Durand
 
Java EE, un ami qui vous veut du bien
Java EE, un ami qui vous veut du bienJava EE, un ami qui vous veut du bien
Java EE, un ami qui vous veut du bienAntoine Sabot-Durand
 
The Magnificent java EE 7 in Wildfly-O-Rama
The Magnificent java EE 7 in Wildfly-O-RamaThe Magnificent java EE 7 in Wildfly-O-Rama
The Magnificent java EE 7 in Wildfly-O-RamaAntoine Sabot-Durand
 
Fais ce que tu veux avec Java EE - Devoxx France 2014
Fais ce que tu veux avec Java EE - Devoxx France 2014Fais ce que tu veux avec Java EE - Devoxx France 2014
Fais ce que tu veux avec Java EE - Devoxx France 2014Antoine Sabot-Durand
 
Architecting Large Enterprise Projects @DevConf.CZ
Architecting Large Enterprise Projects @DevConf.CZArchitecting Large Enterprise Projects @DevConf.CZ
Architecting Large Enterprise Projects @DevConf.CZMarkus Eisele
 
Kids computer-programming
Kids computer-programmingKids computer-programming
Kids computer-programmingEdward Burns
 
Java 8, Streams & Collectors, patterns, performances and parallelization
Java 8, Streams & Collectors, patterns, performances and parallelizationJava 8, Streams & Collectors, patterns, performances and parallelization
Java 8, Streams & Collectors, patterns, performances and parallelizationJosé Paumard
 
CDI mis en pratique avec Seam Social et Weld OSGI
CDI mis en pratique avec Seam Social et Weld OSGICDI mis en pratique avec Seam Social et Weld OSGI
CDI mis en pratique avec Seam Social et Weld OSGIAntoine Sabot-Durand
 

Viewers also liked (12)

Invoke dynamite in Java EE with invoke dynamic
Invoke dynamite in Java EE with invoke dynamicInvoke dynamite in Java EE with invoke dynamic
Invoke dynamite in Java EE with invoke dynamic
 
Going further with CDI 1.2
Going further with CDI 1.2Going further with CDI 1.2
Going further with CDI 1.2
 
Apache DeltaSpike the CDI toolbox
Apache DeltaSpike the CDI toolboxApache DeltaSpike the CDI toolbox
Apache DeltaSpike the CDI toolbox
 
Mute Java EE DNA with CDI
Mute Java EE DNA with CDI Mute Java EE DNA with CDI
Mute Java EE DNA with CDI
 
Java EE, un ami qui vous veut du bien
Java EE, un ami qui vous veut du bienJava EE, un ami qui vous veut du bien
Java EE, un ami qui vous veut du bien
 
The Magnificent java EE 7 in Wildfly-O-Rama
The Magnificent java EE 7 in Wildfly-O-RamaThe Magnificent java EE 7 in Wildfly-O-Rama
The Magnificent java EE 7 in Wildfly-O-Rama
 
Devoxx Java Social and Agorava
Devoxx Java Social and AgoravaDevoxx Java Social and Agorava
Devoxx Java Social and Agorava
 
Fais ce que tu veux avec Java EE - Devoxx France 2014
Fais ce que tu veux avec Java EE - Devoxx France 2014Fais ce que tu veux avec Java EE - Devoxx France 2014
Fais ce que tu veux avec Java EE - Devoxx France 2014
 
Architecting Large Enterprise Projects @DevConf.CZ
Architecting Large Enterprise Projects @DevConf.CZArchitecting Large Enterprise Projects @DevConf.CZ
Architecting Large Enterprise Projects @DevConf.CZ
 
Kids computer-programming
Kids computer-programmingKids computer-programming
Kids computer-programming
 
Java 8, Streams & Collectors, patterns, performances and parallelization
Java 8, Streams & Collectors, patterns, performances and parallelizationJava 8, Streams & Collectors, patterns, performances and parallelization
Java 8, Streams & Collectors, patterns, performances and parallelization
 
CDI mis en pratique avec Seam Social et Weld OSGI
CDI mis en pratique avec Seam Social et Weld OSGICDI mis en pratique avec Seam Social et Weld OSGI
CDI mis en pratique avec Seam Social et Weld OSGI
 

Similar to CDI 2.0 is coming

Prepare to defend thyself with Blue/Green
Prepare to defend thyself with Blue/GreenPrepare to defend thyself with Blue/Green
Prepare to defend thyself with Blue/GreenSonatype
 
All Day DevOps 2016 Fabian - Defending Thyself with Blue Green
All Day DevOps 2016 Fabian - Defending Thyself with Blue GreenAll Day DevOps 2016 Fabian - Defending Thyself with Blue Green
All Day DevOps 2016 Fabian - Defending Thyself with Blue GreenFab L
 
AppSec USA 2014 talk by Chris Swan "Implications & Opportunities at the Bleed...
AppSec USA 2014 talk by Chris Swan "Implications & Opportunities at the Bleed...AppSec USA 2014 talk by Chris Swan "Implications & Opportunities at the Bleed...
AppSec USA 2014 talk by Chris Swan "Implications & Opportunities at the Bleed...Cohesive Networks
 
Java EE & Glass Fish User Group: Digital JavaEE 7 - New and Noteworthy
Java EE & Glass Fish User Group: Digital JavaEE 7 - New and NoteworthyJava EE & Glass Fish User Group: Digital JavaEE 7 - New and Noteworthy
Java EE & Glass Fish User Group: Digital JavaEE 7 - New and NoteworthyPeter Pilgrim
 
JavaEE & GlassFish UG - Digital JavaEE 7 New & Noteworthy by P.Pilgrim
JavaEE & GlassFish UG - Digital JavaEE 7 New & Noteworthy by P.PilgrimJavaEE & GlassFish UG - Digital JavaEE 7 New & Noteworthy by P.Pilgrim
JavaEE & GlassFish UG - Digital JavaEE 7 New & Noteworthy by P.PilgrimPayara
 
FIWARE IoT Proposal & Community
FIWARE IoT Proposal & CommunityFIWARE IoT Proposal & Community
FIWARE IoT Proposal & CommunityFIWARE
 
Building A SaaS with CoreOS, Docker, and Etcd
Building A SaaS with CoreOS, Docker, and EtcdBuilding A SaaS with CoreOS, Docker, and Etcd
Building A SaaS with CoreOS, Docker, and EtcdRoss Kukulinski
 
給 RD 的 Kubernetes 初體驗
給 RD 的 Kubernetes 初體驗給 RD 的 Kubernetes 初體驗
給 RD 的 Kubernetes 初體驗William Yeh
 
Why And When Should We Consider Stream Processing In Our Solutions Teqnation ...
Why And When Should We Consider Stream Processing In Our Solutions Teqnation ...Why And When Should We Consider Stream Processing In Our Solutions Teqnation ...
Why And When Should We Consider Stream Processing In Our Solutions Teqnation ...Soroosh Khodami
 
DockerCon EU 2015: Docker and PCI-DSS - Lessons learned in a security sensiti...
DockerCon EU 2015: Docker and PCI-DSS - Lessons learned in a security sensiti...DockerCon EU 2015: Docker and PCI-DSS - Lessons learned in a security sensiti...
DockerCon EU 2015: Docker and PCI-DSS - Lessons learned in a security sensiti...Docker, Inc.
 
Predicting Space Weather with Docker
Predicting Space Weather with DockerPredicting Space Weather with Docker
Predicting Space Weather with DockerDocker, Inc.
 
3/3 : The path to CDI 2.0 - Antoine Sabot-Durand
3/3 : The path to CDI 2.0 - Antoine Sabot-Durand3/3 : The path to CDI 2.0 - Antoine Sabot-Durand
3/3 : The path to CDI 2.0 - Antoine Sabot-DurandSOAT
 
What does it take to be architect (for Cjicago JUG)
What does it take to be architect (for Cjicago JUG)What does it take to be architect (for Cjicago JUG)
What does it take to be architect (for Cjicago JUG)Constantine Slisenka
 
Tdd & clean code
Tdd & clean codeTdd & clean code
Tdd & clean codeEyal Vardi
 
Probo.ci Drupal 4 Gov Devops 1/2 day Presentation
Probo.ci Drupal 4 Gov Devops 1/2 day Presentation Probo.ci Drupal 4 Gov Devops 1/2 day Presentation
Probo.ci Drupal 4 Gov Devops 1/2 day Presentation Zivtech, LLC
 
Fiware IoT Proposal and Community
Fiware IoT Proposal and CommunityFiware IoT Proposal and Community
Fiware IoT Proposal and CommunityCARLOS RALLI-UCENDO
 
Using Graph Databases in Real-Time to Solve Resource Authorization at Telenor...
Using Graph Databases in Real-Time to Solve Resource Authorization at Telenor...Using Graph Databases in Real-Time to Solve Resource Authorization at Telenor...
Using Graph Databases in Real-Time to Solve Resource Authorization at Telenor...Sebastian Verheughe
 
Chris Swan at QCon 2014: Using Docker in Cloud Networks
Chris Swan at QCon 2014: Using Docker in Cloud NetworksChris Swan at QCon 2014: Using Docker in Cloud Networks
Chris Swan at QCon 2014: Using Docker in Cloud NetworksCohesive Networks
 

Similar to CDI 2.0 is coming (20)

Prepare to defend thyself with Blue/Green
Prepare to defend thyself with Blue/GreenPrepare to defend thyself with Blue/Green
Prepare to defend thyself with Blue/Green
 
All Day DevOps 2016 Fabian - Defending Thyself with Blue Green
All Day DevOps 2016 Fabian - Defending Thyself with Blue GreenAll Day DevOps 2016 Fabian - Defending Thyself with Blue Green
All Day DevOps 2016 Fabian - Defending Thyself with Blue Green
 
AppSec USA 2014 talk by Chris Swan "Implications & Opportunities at the Bleed...
AppSec USA 2014 talk by Chris Swan "Implications & Opportunities at the Bleed...AppSec USA 2014 talk by Chris Swan "Implications & Opportunities at the Bleed...
AppSec USA 2014 talk by Chris Swan "Implications & Opportunities at the Bleed...
 
Cdi from monolith to module
Cdi from monolith to moduleCdi from monolith to module
Cdi from monolith to module
 
Java EE & Glass Fish User Group: Digital JavaEE 7 - New and Noteworthy
Java EE & Glass Fish User Group: Digital JavaEE 7 - New and NoteworthyJava EE & Glass Fish User Group: Digital JavaEE 7 - New and Noteworthy
Java EE & Glass Fish User Group: Digital JavaEE 7 - New and Noteworthy
 
JavaEE & GlassFish UG - Digital JavaEE 7 New & Noteworthy by P.Pilgrim
JavaEE & GlassFish UG - Digital JavaEE 7 New & Noteworthy by P.PilgrimJavaEE & GlassFish UG - Digital JavaEE 7 New & Noteworthy by P.Pilgrim
JavaEE & GlassFish UG - Digital JavaEE 7 New & Noteworthy by P.Pilgrim
 
FIWARE IoT Proposal & Community
FIWARE IoT Proposal & CommunityFIWARE IoT Proposal & Community
FIWARE IoT Proposal & Community
 
Building A SaaS with CoreOS, Docker, and Etcd
Building A SaaS with CoreOS, Docker, and EtcdBuilding A SaaS with CoreOS, Docker, and Etcd
Building A SaaS with CoreOS, Docker, and Etcd
 
給 RD 的 Kubernetes 初體驗
給 RD 的 Kubernetes 初體驗給 RD 的 Kubernetes 初體驗
給 RD 的 Kubernetes 初體驗
 
Why And When Should We Consider Stream Processing In Our Solutions Teqnation ...
Why And When Should We Consider Stream Processing In Our Solutions Teqnation ...Why And When Should We Consider Stream Processing In Our Solutions Teqnation ...
Why And When Should We Consider Stream Processing In Our Solutions Teqnation ...
 
DockerCon EU 2015: Docker and PCI-DSS - Lessons learned in a security sensiti...
DockerCon EU 2015: Docker and PCI-DSS - Lessons learned in a security sensiti...DockerCon EU 2015: Docker and PCI-DSS - Lessons learned in a security sensiti...
DockerCon EU 2015: Docker and PCI-DSS - Lessons learned in a security sensiti...
 
Predicting Space Weather with Docker
Predicting Space Weather with DockerPredicting Space Weather with Docker
Predicting Space Weather with Docker
 
3/3 : The path to CDI 2.0 - Antoine Sabot-Durand
3/3 : The path to CDI 2.0 - Antoine Sabot-Durand3/3 : The path to CDI 2.0 - Antoine Sabot-Durand
3/3 : The path to CDI 2.0 - Antoine Sabot-Durand
 
What does it take to be architect (for Cjicago JUG)
What does it take to be architect (for Cjicago JUG)What does it take to be architect (for Cjicago JUG)
What does it take to be architect (for Cjicago JUG)
 
Micro Frontends
Micro FrontendsMicro Frontends
Micro Frontends
 
Tdd & clean code
Tdd & clean codeTdd & clean code
Tdd & clean code
 
Probo.ci Drupal 4 Gov Devops 1/2 day Presentation
Probo.ci Drupal 4 Gov Devops 1/2 day Presentation Probo.ci Drupal 4 Gov Devops 1/2 day Presentation
Probo.ci Drupal 4 Gov Devops 1/2 day Presentation
 
Fiware IoT Proposal and Community
Fiware IoT Proposal and CommunityFiware IoT Proposal and Community
Fiware IoT Proposal and Community
 
Using Graph Databases in Real-Time to Solve Resource Authorization at Telenor...
Using Graph Databases in Real-Time to Solve Resource Authorization at Telenor...Using Graph Databases in Real-Time to Solve Resource Authorization at Telenor...
Using Graph Databases in Real-Time to Solve Resource Authorization at Telenor...
 
Chris Swan at QCon 2014: Using Docker in Cloud Networks
Chris Swan at QCon 2014: Using Docker in Cloud NetworksChris Swan at QCon 2014: Using Docker in Cloud Networks
Chris Swan at QCon 2014: Using Docker in Cloud Networks
 

Recently uploaded

Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Best Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfBest Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfIdiosysTechnologies1
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 

Recently uploaded (20)

Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Best Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdfBest Web Development Agency- Idiosys USA.pdf
Best Web Development Agency- Idiosys USA.pdf
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 

CDI 2.0 is coming

  • 2.
  • 3. @antoine_sd @JosePaumard#Devoxx #CDI2 Agenda  Flashback on CDI 1.0, 1.1 and 1.2  CDI 2.0 status  Gathering feedback for CDI 2.0  CDI 2.0 new features  Questions and Feedback
  • 5. CDI Timeline Dec 2009 June 2013 Apr 2014 Sep 2014 2016
  • 6. @antoine_sd @JosePaumard#Devoxx #CDI2 CDI 1.0 – December 2009  A typesafe dependency injection mechanism  A well-defined lifecycle for stateful objects  The ability to decorate or to associate interceptors to objects with a typesafe approach  An event notification model  An SPI allowing portable extensions
  • 7. @antoine_sd @JosePaumard#Devoxx #CDI2 CDI 1.1 – June 2013  CDI is automatically enabled in Java EE  Introspection with bean, events, decorator and interceptor metadata  Ease access to CDI from non CDI code  Work on interceptor for reuse by other Java EE specs  SPI enhancement for portable extensions
  • 8. @antoine_sd @JosePaumard#Devoxx #CDI2 CDI 1.2 – April 2014  Clarifications in the spec • Lifecycles • Events • Conversation scope  Fix conflict with other JSR 330 frameworks  OSGi support in the API
  • 9. @antoine_sd @JosePaumard#Devoxx #CDI2 CDI 2.0 started 12 months ago  JSR 365! • First Java EE 8 JSR proposed and voted  Weekly IRC meeting  Regular release of Weld 3.0 Alpha (CDI 2.0 RI)  We have a lot of community momentum  Early Draft was released this summer  Release expected in 2016 (Q2?)
  • 10. @antoine_sd @JosePaumard#Devoxx #CDI2 EG members  Pete Muir (Red Hat)  Antoine Sabot-Durand (Red Hat)  José Paumard  John Ament  David Currie (IBM)  Anatole Tresch (Credit Suisse)  Antonio Goncalves  Thorben Janssen  Raj. Hegde (JUG Chennai)  Werner Keil  Joseph Snyder (Oracle)  Mark Paluch  Florent Benoit (SERLI)  Mark Struberg  David Blevins (Tomitribe)  George Gastaldi (Red Hat)  Otavio Santana
  • 11. @antoine_sd @JosePaumard#Devoxx #CDI2 We are open to the community!
  • 13.
  • 14. @antoine_sd @JosePaumard#Devoxx #CDI2 CDI 2.0 survey 260 participants 20 features to rate
  • 15. @antoine_sd @JosePaumard#Devoxx #CDI2 1st feature  Asynchronous support for events and method invocation
  • 16. @antoine_sd @JosePaumard#Devoxx #CDI2 Other top requested features  @Startup for CDI  Bootstraping outside of Java EE  AOP for custom beans  Security support  Observers ordering, better event control  Access to metadata through SPI
  • 17. CDI 2.0 new features
  • 18. Java SE support Using CDI outside of the Java EE Container
  • 19. @antoine_sd @JosePaumard#Devoxx #CDI2 Why that?  To ease the testing of CDI applications  To provide a mean of building new stacks out of Java EE  To boost CDI adoption for Spec working already on Java SE  First step before working on a CDI light
  • 20. @antoine_sd @JosePaumard#Devoxx #CDI2 Java SE support will start in EDR1  We specified API to boot CDI in Java SE:  Desktop and non Java EE application can now use a standard way to boot CDI public static void main(String... args) { CDIProvider provider = CDI.getCDIProvider(); CDI<Object> cdi = provider.initialize(); // retrieve a bean and do work with it MyBean myBean = cdi.select(MyBean.class).get(); myBean.doWork(); // when done cdi.shutdown(); }
  • 21. @antoine_sd @JosePaumard#Devoxx #CDI2 What did we do? CDI Specification CDI Core CDI for Java EE CDI for Java SE
  • 22. @antoine_sd @JosePaumard#Devoxx #CDI2 There’s still work to do  What about built-in contexts activation in Java SE? • RequestScoped, SessionScoped, ConversationScoped…  Answer: we may introduce a new scope • MethodScoped • Living only during method invocation • Activated by an Interceptor • Discussion is in early stage on that
  • 23. @antoine_sd @JosePaumard#Devoxx #CDI2 There’s still work to do  What about bean discovery in Java SE? • Annotated mode can be very costly • Implicit bean archive is disable now  Answer: we are working on SE enhancement • Take more SE features from weld • Choose bean discovery mode at build time • Adding classes / packages explicitly at build time
  • 24. Modularity Provide sub specs in CDI (called parts) that can be used independently Each part should have an implementation
  • 25. @antoine_sd @JosePaumard#Devoxx #CDI2 Why that?  To avoid the “bloated spec” syndrom  Having parts will help CDI adoption  Third party won’t have to implement the whole spec if they don’t want to
  • 26. @antoine_sd @JosePaumard#Devoxx #CDI2 Full CDI - Events - Normal scopes - Interceptor & Decorator - Advanced SPI Modularity – 2 core parts CDI Light - Basic DI - Producers - Programmatic lookup - Singleton and dependent scopes - Basic SPI for integration
  • 27. @antoine_sd @JosePaumard#Devoxx #CDI2 Modularity – challenges  Will bring 4 subspec: • CDI light for Java SE • CDI full for Java SE • CDI light for Java EE • CDI full for Java EE  Having an RI and TCK for each part can be an important work
  • 28. Enhancing events Making a popular feature even more popular!
  • 29. @antoine_sd @JosePaumard#Devoxx #CDI2 Enhancing Events  CDI events are a very loved feature! For CDI 2.0, we plan to introduce :  Asynchronous events  Events ordering
  • 30. @antoine_sd @JosePaumard#Devoxx #CDI2 Events in CDI 1.x: patterns  Firing pattern: @Inject Event<Payload> event; public void someBSCriticalBusinessMethod() throws WTFException { event.fire(new Payload()); }
  • 31. @antoine_sd @JosePaumard#Devoxx #CDI2 Events in CDI 1.x: patterns  Observing pattern:  Supports qualifiers and many other things public void callMe(@Observes Payload payload) { // Do something with the event }
  • 32. @antoine_sd @JosePaumard#Devoxx #CDI2 CDI 1.x: Sync / Async  Sync / Async is not specified  The immutable status of the payload is not specified  Implementations use a Sync model  The payload is mutated in some implementations / framework  Going async “blindly” might raise problems…
  • 33. @antoine_sd @JosePaumard#Devoxx #CDI2 Events are sync in CDI 1 Right now:  All the observers are called in the firing thread  In no particular order (at least not specified)  The payload may be mutated
  • 34. @antoine_sd @JosePaumard#Devoxx #CDI2 Events and contexts Contexts  Two contexts are critical: transactions and HTTP requests / sessions  Events are aware of those contexts  In an all-sync world, everything is fine  But in an async world, we will be in trouble
  • 35. @antoine_sd @JosePaumard#Devoxx #CDI2 Asynchronous Events  So designing backward compatible async events is more tricky than it looks: 1) A currently sync event should remain sync 2) Going sync / async should be a decision taken from the firing side 3) Being sync should be possible from the observing side
  • 36. @antoine_sd @JosePaumard#Devoxx #CDI2 Asynchronous Events  Pattern for the firing side: @Inject Event<Payload> event; public void someEvenMoreCriticalBusinessMethod() { event.fireAsync(new Payload()); }
  • 37. @antoine_sd @JosePaumard#Devoxx #CDI2 Asynchronous Events  Pattern for the observing side: public void callMe(@Observes Payload payload) { // I am called in the firing thread // Whether is was async fired or not } public void callMe(@ObservesAsync Payload payload) { // I am called in another thread }
  • 38. @antoine_sd @JosePaumard#Devoxx #CDI2 Asynchronous Events  So, in a nutshell callMe( @Observes payload) callMe( @ObservesAsync payload) event .fire(payload) Sync call Not notified event .fireAsync(payload) Not notified Async call
  • 39. @antoine_sd @JosePaumard#Devoxx #CDI2 What about mutable payloads?  One short answer:  Don’t do it!  Or suffer the full penalty of race conditions!
  • 40. @antoine_sd @JosePaumard#Devoxx #CDI2 We have some more  Let us come back to this pattern:  1st question: in what thread are the observers going to be called? @Inject Event<Payload> event; public void someOtherCriticalBusinessMethod() { event.fireAsync(new Payload()); }
  • 41. @antoine_sd @JosePaumard#Devoxx #CDI2 We have some more  Let us come back to this pattern:  2nd question: what if exceptions are thrown by the observers? @Inject Event<Payload> event; public void someOtherCriticalBusinessMethod() { event.fireAsync(new Payload()); }
  • 42. @antoine_sd @JosePaumard#Devoxx #CDI2 Adding an Executor to fireAsync  What if the observer needs to be called in the GUI thread? @Inject Event<PanelUpdater> event; public void someOtherCriticalBusinessMethod() { event.fireAsync(new PanelUpdater(green), executor); // Of type Executor }
  • 43. @antoine_sd @JosePaumard#Devoxx #CDI2 Adding an Executor to fireAsync  What if the observer needs to be called in the GUI thread? @Inject Event<PanelUpdater> event; public void someOtherCriticalBusinessMethod() { event.fireAsync(new PanelUpdater(green), SwingUtilities::invokeLater); }
  • 44. @antoine_sd @JosePaumard#Devoxx #CDI2 Handling exceptions  The firing async is built on the Java 8 async model: CompletionStage @Inject Event<PanelUpdater> event; public void someOtherCriticalBusinessMethod() { CompletionStage<PanelUpdater> stage = event.fireAsync(new PanelUpdater(green), SwingUtilities::invokeLater); }
  • 45. @antoine_sd @JosePaumard#Devoxx #CDI2 Handling exceptions  Three ways of handling exceptions: Returns a new CompletionStage  That completes when the CS completes  Either with the same result (normal completion)  Or with the transformed exception stage.exceptionaly( // Function exception -> doSomethingNotTooStupidWith(exception));
  • 46. @antoine_sd @JosePaumard#Devoxx #CDI2 Handling exceptions  Three ways of handling exceptions: Returns a new CompletionStage  That completes when the CS completes  Calls the BiFunction with a null as result or exception  As a bonus: observers can return objects! stage.handle( // BiFunction (result, exception) -> doSomethingWith(result, exception));
  • 47. @antoine_sd @JosePaumard#Devoxx #CDI2 Handling exceptions  Three ways of handling exceptions:  The returned exception is a FireAsyncException  It holds all the exceptions in the suppressed exception set stage.handle( // BiFunction (result, exception) -> doSomethingWith(result, exception));
  • 48. @antoine_sd @JosePaumard#Devoxx #CDI2 Handling exceptions  Three ways of handling exceptions: stage.whenComplete( // BiConsumer, also async version (result, exception) -> doSomethingWith(result, exception));
  • 49. @antoine_sd @JosePaumard#Devoxx #CDI2 Events ordering  Pattern:  Ordering in async… possible but complex public void firstObserver(@Observes @Priority(1) Payload p) {} public void secondObserver(@Observes @Priority(2) Payload p) {}
  • 51. @antoine_sd @JosePaumard#Devoxx #CDI2 Support AOP on producer  In CDI 1.x you cannot bind an interceptor to a produced bean  When you write:  @Transactional is applied to producer method @Produces @Transactional public MyService produceService() { ... }
  • 52. @antoine_sd @JosePaumard#Devoxx #CDI2 Support AOP on producer  We are working on an instance builder.  Inspired by the UnManaged class  This builder could take an AnnotatedType to know where adding interceptor bindings
  • 53. @antoine_sd @JosePaumard#Devoxx #CDI2 BeanInstanceBuilder example @Produces @RequestScoped public MyClass produceTransactionalMyClass() { BeanInstanceBuilder<MyClass> bib = new BeanInstanceBuilder<>(); AnnotatedTypeBuilder<MyClass> atb = new AnnotatedTypeBuilder<>() .readFrom(MyClass.class) .addToMethod(MyClass.class.getMethod("performInTransaction"), new TransactionalLiteral()); return bib.readFromType(atb.build()).build(); }
  • 55. Which JSR you’ll use 365 days a year? JSR 365!!
  • 56. @antoine_sd @JosePaumard#Devoxx #CDI2 CDI 2.0 needs you!! CDI 2.0 specification is open to everyone Mailing list, IRC channel http://cdi-spec.org @cdispec