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

Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 

Recently uploaded (20)

Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 

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