SlideShare a Scribd company logo
@antoine_sd
CDI from monolith
to modularity
Antoine Sabot-Durand
Red Hat
CDI spec lead
@antoine_sd
Me, Myself and I
Antoine Sabot-Durand
Java Champion at Red Hat
Commiter on MicroProfile
CDI spec lead
Follow me: @antoine_sd
Follow CDI: @cdispec
@antoine_sd
Agenda
The Past
CDI as part of Java EE
The Present
CDI as part of Microprofile
CDI 2.0 on Java SE
The future
CDI in modular application
Previously on CDI
@antoine_sd
CDI Timeline
Dec 2009 June 2013 Apr 2014 Sep 2014
CDI1.0
(Java
EE
6)
CDI1.1
(Java
EE
7)
CDI1.2
(1.1
MR)
CDI2.0
Starts
Mai 2017
CDI2.0
released
@antoine_sd
CDI 1.x corner stone for Java EE
From Java EE 6 to Java EE 7, CDI has became centric thanks to:
Powerful SPI
EJB integration (to switch from EJB to CDI)
Events
@antoine_sd
CDI present
@antoine_sd
CDI corner stone for MicroProfile
MicroProfile is built on top of CDI and JAX-RS
MicroProfile 2.0 adopted CDI 2.0 (latest version MicroProfile 2.1)
@antoine_sd
CDI 2.0 brings CDI SE into play
public static void main(String[] args) {



SeContainer container = SeContainerInitializer.newInstance()

.disableDiscovery()

.addBeanClasses(MyService.class)

.initialize();



MyService service = container.select(MyService.class).get();



service.sayHello();



container.close();

}
@antoine_sd
CDI Future
@antoine_sd
CDI Future is multiple
Enhance CDI SPI to provide a better integration with other specs
Make CDI more reactive (i.e. support asynchronous bean resolution)
Make CDI app Jigsaw compatible
@antoine_sd
CDI Future is multiple
Enhance CDI SPI to provide a better integration with other specs
Make CDI more reactive (i.e. support asynchronous bean resolution)
Make CDI development Jigsaw (JPMS) compatible
@antoine_sd
Why CDI + JPMS?
To reduce deployment size for MicroServices
To Produce standalone images with Jlink
As CDI is centric moving in that direction will impact MicroProfile
@antoine_sd
Catching up on JPMS
JPMS = Modularized JDK and modules for your applications
Strong encapsulation
Clearly defined APIs
Explicit relationships
@antoine_sd
3 steps to move to JPMS
Build on Java 9+
Move to automatic modules
Move to named modules
@antoine_sd
3 steps to move to JPMS
Step 1 - Build on Java 9:
The class path still exists!
Often works fine
Be wary of Java EE dependences (JAXB, @Generated etc.) and jdk.unsupported
Time for some clean-up
Watch out for illegal access warnings
Remove split packages
Remove circular dependencies (services can help)
@antoine_sd
3 steps to move to JPMS
Step 2 - Automatic Modules
Use non-modular JARs on module path
Read all resolved modules and the classpath ("UNNAMED" module)
Export all packages
Define module name via Automatic-Module-Name manifest entry
Send patches to your deps with module name in MANIFEST.MF
@antoine_sd
3 steps to move to JPMS
Step 3 - Named Modules
Declare module-info descriptor
No Jlink image without named module
Carefully decide on
API
dependences ("Do I really need java.desktop?")
ModiTect is a tool that can help you to do that
@antoine_sd
Anatomy of a module descriptor
module com.example {
requires java.sql;
requires joda.time;
requires com.google.guava;
exports com.example.foo;
exports com.example.foo.bar;
exports com.example.foo.baz;
uses com.acme.SomeService;
provides com.acme.AnotherService with com.example.internal.MyServiceImpl;
}
@antoine_sd
Moditect
A project developed by Gunnar Morling
https://github.com/moditect/moditect
Provides a Maven Plugin
Useful tool to add modularity to non modular jar
Also useful to produce jlink image
Demo
@antoine_sd
CDI-JLINK repo
CDI-JLINK repo is here:

https://github.com/antoinesd/cdi-jlink
Don’t skip the readme !

More Related Content

PDF
Java 9, JShell, and Modularity
Mohammad Hossein Rimaz
 
PPTX
Java 9 Module System Introduction
Dan Stine
 
PDF
A Journey through the JDKs (Java 9 to Java 11)
Markus Günther
 
PDF
QConSP 2018 - Java Module System
Leonardo Zanivan
 
PPTX
Preparing for java 9 modules upload
Ryan Cuprak
 
PDF
EJB and CDI - Alignment and Strategy
David Delabassee
 
PDF
Hybrid Cloud Application Development without vendor lockin
EmilyJiang23
 
PDF
Eclipse MicroProfile: Accelerating Cloud-Native Application Development with ...
Thabang Mashologu
 
Java 9, JShell, and Modularity
Mohammad Hossein Rimaz
 
Java 9 Module System Introduction
Dan Stine
 
A Journey through the JDKs (Java 9 to Java 11)
Markus Günther
 
QConSP 2018 - Java Module System
Leonardo Zanivan
 
Preparing for java 9 modules upload
Ryan Cuprak
 
EJB and CDI - Alignment and Strategy
David Delabassee
 
Hybrid Cloud Application Development without vendor lockin
EmilyJiang23
 
Eclipse MicroProfile: Accelerating Cloud-Native Application Development with ...
Thabang Mashologu
 

Similar to Cdi from monolith to module (20)

PDF
IBM JavaOne Community Keynote 2017
John Duimovich
 
PDF
We Can Do Better - IBM's Vision for the Next Generation of Java Runtimes - Jo...
mfrancis
 
PDF
Modules all the way down: OSGi and the Java Platform Module System
Tim Ellison
 
PPT
Java 9 Module System
Hasan Ünal
 
PDF
Haj 4344-java se 9 and the application server-1
Kevin Sutter
 
DOC
Next-Generation Enterprise Application Development with SpringSource dm Serve...
Aditya Jha
 
PDF
Javantura v4 - What’s NOT new in modular Java - Milen Dyankov
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
PPTX
A first Draft to Java Configuration
Anatole Tresch
 
PDF
JavaOne 2016: Life after Modularity
DanHeidinga
 
PDF
Creando microservicios con java micro profile y tomee - CUNORI 2020
César Hernández
 
PDF
Production Time Profiling and Diagnostics on the JVM
Marcus Hirt
 
PPTX
Java 9: Deep Dive into Modularity and Dealing with Migration Issues
GlobalLogic Ukraine
 
PDF
Java 9 and Project Jigsaw
DPC Consulting Ltd
 
PPTX
Simple tweaks to get the most out of your JVM
Jamie Coleman
 
PDF
Lightweight Java EE with MicroProfile
Josh Juneau
 
PDF
Business Value of Java Microservices with Eclipse Microprofile eBook
Thabang Mashologu
 
PDF
Modular Java EE in the Cloud
Bert Ertman
 
PPTX
Introduction to Eclipse Microprofile
Red Hat Developers
 
PPTX
Simple tweaks to get the most out of your jvm
Jamie Coleman
 
PPTX
FOSDEM 2017 - Open J9 The Next Free Java VM
Charlie Gracie
 
IBM JavaOne Community Keynote 2017
John Duimovich
 
We Can Do Better - IBM's Vision for the Next Generation of Java Runtimes - Jo...
mfrancis
 
Modules all the way down: OSGi and the Java Platform Module System
Tim Ellison
 
Java 9 Module System
Hasan Ünal
 
Haj 4344-java se 9 and the application server-1
Kevin Sutter
 
Next-Generation Enterprise Application Development with SpringSource dm Serve...
Aditya Jha
 
Javantura v4 - What’s NOT new in modular Java - Milen Dyankov
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
A first Draft to Java Configuration
Anatole Tresch
 
JavaOne 2016: Life after Modularity
DanHeidinga
 
Creando microservicios con java micro profile y tomee - CUNORI 2020
César Hernández
 
Production Time Profiling and Diagnostics on the JVM
Marcus Hirt
 
Java 9: Deep Dive into Modularity and Dealing with Migration Issues
GlobalLogic Ukraine
 
Java 9 and Project Jigsaw
DPC Consulting Ltd
 
Simple tweaks to get the most out of your JVM
Jamie Coleman
 
Lightweight Java EE with MicroProfile
Josh Juneau
 
Business Value of Java Microservices with Eclipse Microprofile eBook
Thabang Mashologu
 
Modular Java EE in the Cloud
Bert Ertman
 
Introduction to Eclipse Microprofile
Red Hat Developers
 
Simple tweaks to get the most out of your jvm
Jamie Coleman
 
FOSDEM 2017 - Open J9 The Next Free Java VM
Charlie Gracie
 
Ad

More from Antoine Sabot-Durand (20)

PDF
What's new in CDI 2.0
Antoine Sabot-Durand
 
PDF
CDI 2.0 is upon us Devoxx
Antoine Sabot-Durand
 
PDF
CDI 2.0 is coming
Antoine Sabot-Durand
 
PDF
Mute Java EE DNA with CDI
Antoine Sabot-Durand
 
PDF
Extending Java EE with CDI and JBoss Forge
Antoine Sabot-Durand
 
PDF
CDI 2.0 is coming
Antoine Sabot-Durand
 
PDF
Apache Deltaspike the CDI Toolbox (Java One 2015)
Antoine Sabot-Durand
 
PDF
Advanced CDI in live coding
Antoine Sabot-Durand
 
PDF
Java EE, un ami qui vous veut du bien
Antoine Sabot-Durand
 
PDF
Adopt a JSR: CDI 2.0 at Devoxx UK
Antoine Sabot-Durand
 
PDF
Apache DeltaSpike the CDI toolbox
Antoine Sabot-Durand
 
PDF
Going further with CDI 1.2
Antoine Sabot-Durand
 
PDF
The path to cdi 2.0
Antoine Sabot-Durand
 
PDF
Introduction to cdi given at java one 2014
Antoine Sabot-Durand
 
PDF
Invoke dynamite in Java EE with invoke dynamic
Antoine Sabot-Durand
 
PDF
CDI 1.1 university
Antoine Sabot-Durand
 
PDF
Fais ce que tu veux avec Java EE - Devoxx France 2014
Antoine Sabot-Durand
 
PDF
CDI In Real Life
Antoine Sabot-Durand
 
PDF
The Magnificent java EE 7 in Wildfly-O-Rama
Antoine Sabot-Durand
 
PDF
Devoxx Java Social and Agorava
Antoine Sabot-Durand
 
What's new in CDI 2.0
Antoine Sabot-Durand
 
CDI 2.0 is upon us Devoxx
Antoine Sabot-Durand
 
CDI 2.0 is coming
Antoine Sabot-Durand
 
Mute Java EE DNA with CDI
Antoine Sabot-Durand
 
Extending Java EE with CDI and JBoss Forge
Antoine Sabot-Durand
 
CDI 2.0 is coming
Antoine Sabot-Durand
 
Apache Deltaspike the CDI Toolbox (Java One 2015)
Antoine Sabot-Durand
 
Advanced CDI in live coding
Antoine Sabot-Durand
 
Java EE, un ami qui vous veut du bien
Antoine Sabot-Durand
 
Adopt a JSR: CDI 2.0 at Devoxx UK
Antoine Sabot-Durand
 
Apache DeltaSpike the CDI toolbox
Antoine Sabot-Durand
 
Going further with CDI 1.2
Antoine Sabot-Durand
 
The path to cdi 2.0
Antoine Sabot-Durand
 
Introduction to cdi given at java one 2014
Antoine Sabot-Durand
 
Invoke dynamite in Java EE with invoke dynamic
Antoine Sabot-Durand
 
CDI 1.1 university
Antoine Sabot-Durand
 
Fais ce que tu veux avec Java EE - Devoxx France 2014
Antoine Sabot-Durand
 
CDI In Real Life
Antoine Sabot-Durand
 
The Magnificent java EE 7 in Wildfly-O-Rama
Antoine Sabot-Durand
 
Devoxx Java Social and Agorava
Antoine Sabot-Durand
 
Ad

Recently uploaded (20)

PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
PDF
Doc9.....................................
SofiaCollazos
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
PDF
Software Development Methodologies in 2025
KodekX
 
PDF
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PDF
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
PDF
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
PDF
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PDF
REPORT: Heating appliances market in Poland 2024
SPIUG
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PDF
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
Doc9.....................................
SofiaCollazos
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
Software Development Methodologies in 2025
KodekX
 
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
REPORT: Heating appliances market in Poland 2024
SPIUG
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
AI-Cloud-Business-Management-Platforms-The-Key-to-Efficiency-Growth.pdf
Artjoker Software Development Company
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 

Cdi from monolith to module

  • 1. @antoine_sd CDI from monolith to modularity Antoine Sabot-Durand Red Hat CDI spec lead
  • 2. @antoine_sd Me, Myself and I Antoine Sabot-Durand Java Champion at Red Hat Commiter on MicroProfile CDI spec lead Follow me: @antoine_sd Follow CDI: @cdispec
  • 3. @antoine_sd Agenda The Past CDI as part of Java EE The Present CDI as part of Microprofile CDI 2.0 on Java SE The future CDI in modular application
  • 5. @antoine_sd CDI Timeline Dec 2009 June 2013 Apr 2014 Sep 2014 CDI1.0 (Java EE 6) CDI1.1 (Java EE 7) CDI1.2 (1.1 MR) CDI2.0 Starts Mai 2017 CDI2.0 released
  • 6. @antoine_sd CDI 1.x corner stone for Java EE From Java EE 6 to Java EE 7, CDI has became centric thanks to: Powerful SPI EJB integration (to switch from EJB to CDI) Events
  • 8. @antoine_sd CDI corner stone for MicroProfile MicroProfile is built on top of CDI and JAX-RS MicroProfile 2.0 adopted CDI 2.0 (latest version MicroProfile 2.1)
  • 9. @antoine_sd CDI 2.0 brings CDI SE into play public static void main(String[] args) {
 
 SeContainer container = SeContainerInitializer.newInstance()
 .disableDiscovery()
 .addBeanClasses(MyService.class)
 .initialize();
 
 MyService service = container.select(MyService.class).get();
 
 service.sayHello();
 
 container.close();
 }
  • 11. @antoine_sd CDI Future is multiple Enhance CDI SPI to provide a better integration with other specs Make CDI more reactive (i.e. support asynchronous bean resolution) Make CDI app Jigsaw compatible
  • 12. @antoine_sd CDI Future is multiple Enhance CDI SPI to provide a better integration with other specs Make CDI more reactive (i.e. support asynchronous bean resolution) Make CDI development Jigsaw (JPMS) compatible
  • 13. @antoine_sd Why CDI + JPMS? To reduce deployment size for MicroServices To Produce standalone images with Jlink As CDI is centric moving in that direction will impact MicroProfile
  • 14. @antoine_sd Catching up on JPMS JPMS = Modularized JDK and modules for your applications Strong encapsulation Clearly defined APIs Explicit relationships
  • 15. @antoine_sd 3 steps to move to JPMS Build on Java 9+ Move to automatic modules Move to named modules
  • 16. @antoine_sd 3 steps to move to JPMS Step 1 - Build on Java 9: The class path still exists! Often works fine Be wary of Java EE dependences (JAXB, @Generated etc.) and jdk.unsupported Time for some clean-up Watch out for illegal access warnings Remove split packages Remove circular dependencies (services can help)
  • 17. @antoine_sd 3 steps to move to JPMS Step 2 - Automatic Modules Use non-modular JARs on module path Read all resolved modules and the classpath ("UNNAMED" module) Export all packages Define module name via Automatic-Module-Name manifest entry Send patches to your deps with module name in MANIFEST.MF
  • 18. @antoine_sd 3 steps to move to JPMS Step 3 - Named Modules Declare module-info descriptor No Jlink image without named module Carefully decide on API dependences ("Do I really need java.desktop?") ModiTect is a tool that can help you to do that
  • 19. @antoine_sd Anatomy of a module descriptor module com.example { requires java.sql; requires joda.time; requires com.google.guava; exports com.example.foo; exports com.example.foo.bar; exports com.example.foo.baz; uses com.acme.SomeService; provides com.acme.AnotherService with com.example.internal.MyServiceImpl; }
  • 20. @antoine_sd Moditect A project developed by Gunnar Morling https://github.com/moditect/moditect Provides a Maven Plugin Useful tool to add modularity to non modular jar Also useful to produce jlink image
  • 21. Demo
  • 22. @antoine_sd CDI-JLINK repo CDI-JLINK repo is here:
 https://github.com/antoinesd/cdi-jlink Don’t skip the readme !