3/3 : The path to CDI 2.0 - Antoine Sabot-Durand

16
CDI 2.0 new features

description

Allez plus Loin avec CDI En moins de 5 ans d’existence, Contexts and Dependency Injection (CDI) est devenue l’une des principale spécification de Java EE. Néanmoins, CDI est bien souvent perçu comme une simple solution d’injection de dépendance enrichie alors que cette spécification est bien plus riche que ça. Lors de cette présentation, après un rapide rappel des fonctionnalités de base de CDI, nous montrerons comment son utilisation avancée permet Java EE en intégrant des technologies legacy ou plus récent de manière naturelle. Nous finirons avec le travail en cours sur CDI 2.0 qui a commencé début septembre.

Transcript of 3/3 : The path to CDI 2.0 - Antoine Sabot-Durand

Page 1: 3/3 : The path to CDI 2.0 - Antoine Sabot-Durand

CDI 2.0 new features

Page 2: 3/3 : The path to CDI 2.0 - Antoine Sabot-Durand
Page 3: 3/3 : The path to CDI 2.0 - Antoine Sabot-Durand

ModularityProvide sub specs in CDI (called parts) that can be used independently

Each part should have an implementation

Page 4: 3/3 : The path to CDI 2.0 - Antoine Sabot-Durand

Modularity - Why ?

We want to add new features to CDI without making it a bloated spec

Having parts will help CDI adoption. Third party won’t have to get the whole spec and impl if they don’t want to

Page 5: 3/3 : The path to CDI 2.0 - Antoine Sabot-Durand

Modularity - What parts ?

Right now we are thinking of 3 parts :

CDI Light : DI and events without normal scope and AOP

Providing lighter CDI implementations

Full CDI

Full CDI with Java EE / other spec integration

Page 6: 3/3 : The path to CDI 2.0 - Antoine Sabot-Durand

Modularity - challenges

Be sure of the parts - too much or not enough granularity

Having an RI and TCK for each part can be an important work

Page 7: 3/3 : The path to CDI 2.0 - Antoine Sabot-Durand

Java SE supportusing CDI outside Java EE

Page 8: 3/3 : The path to CDI 2.0 - Antoine Sabot-Durand

Java SE support - Why?

To provide a mean of building new stacks out of Java EE

To boost CDI adoption for Spec working already on Java SE

Page 9: 3/3 : The path to CDI 2.0 - Antoine Sabot-Durand

Java SE support - challengesExtract “Java EE” features across the spec to create a chapter dedicated to it

Decide what existing SE support we standardise

Add SPI for CDI integration with standard services:

JPA

Transaction

Security

Page 10: 3/3 : The path to CDI 2.0 - Antoine Sabot-Durand

Enhancing eventsMaking popular feature even more popular

Page 11: 3/3 : The path to CDI 2.0 - Antoine Sabot-Durand

Asynchronous Events

@InjectEvent<Payload> evt;

public void fireAsyncWithCallBack() { evt.fireAsync(new Payload(), callBack -> System.out.println("Job done”));}

Using lambdas to provide optional callback

Page 12: 3/3 : The path to CDI 2.0 - Antoine Sabot-Durand

Events Ordering

public void firstObserver(@Observes(1) Payload pl) {}

public void secondObserver(@Observes(2) Payload pl) {}

Page 13: 3/3 : The path to CDI 2.0 - Antoine Sabot-Durand

AOP enhancement

Support AOP on custom or produced bean

Improve interceptor chaining

Support Self Injection to call intercepted / decorated method from the same bean

Page 14: 3/3 : The path to CDI 2.0 - Antoine Sabot-Durand

SPI and contexts enhancement

Standardise CDI boot

Add helpers to create new metadata:

AnnotatedTypeBuilder

BeanBuilder

Add SPI to activate / deactivate contexts

Page 15: 3/3 : The path to CDI 2.0 - Antoine Sabot-Durand

CDI 2.0 needs you

CDI 2.0 specification is open to everyone

Come on join us on the mailing list and IRC channel

All infos on http://cdi-spec.org or by following to @cdispec on twitter

The more we are the more we’ll deliver

Page 16: 3/3 : The path to CDI 2.0 - Antoine Sabot-Durand

Questions ?