SlideShare ist ein Scribd-Unternehmen logo
1 von 31
Downloaden Sie, um offline zu lesen
JavaOne
@dblevins @tomitribe#EJBCDI
EJB/CDI Alignment
(What Does It Mean?)
David Blevins
Tomitribe
Jean-Louis Monteiro
Tomitribe
JavaOne
@dblevins @tomitribe#EJBCDI
CDI - EJB Alignment
(understand the conversation)
JavaOne
@dblevins @tomitribe#EJBCDI
CDI History In Brief
JavaOne
@dblevins @tomitribe#EJBCDI
CDI Influences
• Dependency Injection
• Definite Spring influence
• Strong Google Guice syntax
• Originally called “WebBeans”
• Grew from Seam
• Glued JSF and EJB together
JavaOne
@dblevins @tomitribe#EJBCDI
CDI Behind the Scenes
• Achieved through sneaky interceptor trick
• Caused major delay to the Java EE 6 delivery
• Almost didn’t make it
• Criticized for going too far
• Stepped on EE toes (spec overlap)
• Stepped on SE toes (too “enterprisey”)
JavaOne
@dblevins @tomitribe#EJBCDI
CDI Rifts
• Creation of @ManagedBean spec at EE level
• Fuzzy aim at unifying EE component models
• Effort to not lose ground in EE
• Too ambiguous
• Creation of @Inject spec at SE level
• Fuzzy aim at being simpler version of the standard
• Effort to not lose ground in SE
• Too simple, no spec
JavaOne
@dblevins @tomitribe#EJBCDI
EJB Shortcomings
• Legacy
• Reputation
• Fully loaded by default
• Every method starts a transaction
• Throwing an exception destroys the instance
• Instances are non-concurrent
JavaOne
@dblevins @tomitribe#EJBCDI
CDI Takeover
• EJB adopts CDI (Java EE 6)
• JSF adopts CDI (Java EE 7)
• MVC adopts CDI (Java EE 8)
• JAX-RS considers CDI (Java EE 8)
• CDI moves to SE (Java EE 8)
JavaOne
@dblevins @tomitribe#EJBCDI
Result for EJB?
• Java EE 7
• Focus on realignment: @Transactional
• Java EE 8
• First spec round with no new EJB JSR
• Realignment stalled
• Awkward relationship
JavaOne
@dblevins @tomitribe#EJBCDI
CDI from an EJB perspective
JavaOne
@dblevins @tomitribe#EJBCDI
Proxy
(Fake)
Proxy
(Fake)
Interceptors
Decorators
Instance
(Real)
Security
Transaction
Interceptors
Decorators
Instance
(Real)
1. Resolution
2. Services
3. Invocation
(Pool)
1. Resolution
2. Services
3. Invocation
(Context/Scope)
CDI 1.0 EJB 3.1
JavaOne
@dblevins @tomitribe#EJBCDI
Proxy
(Fake)
Proxy
(Fake)
Security
Transaction
Interceptors
Decorators
Instance
(Real)
1. Resolution
2. Services
3. Invocation
(Pool)
1. Resolution
2. Services
3. Invocation
(Context/Scope)
CDI 1.1 EJB 3.2
Transaction
Interceptors
Decorators
Instance
(Real)
JavaOne
@dblevins @tomitribe#EJBCDI
Lifecycle Lineup
• @Singleton
• same as CDI @ApplicationScoped
• @Stateful
• applies to any CDI Scope, not just @SessionScoped
• @Stateless
• no CDI equivalent
• @RequestScoped sort of close(ish)
JavaOne
@dblevins @tomitribe#EJBCDI
Awesome Power of Scopes
JavaOne
@dblevins @tomitribe#EJBCDI
http://tomitribe.io/projects/
microscoped
JavaOne
@dblevins @tomitribe#EJBCDI
Common Mistakes you will make
• Not putting a beans.xml in your app (Java EE 6)
• No CDI for you!
• Not understanding @Typed
• Psst, think @Local from EJB
• Bites you when using @Produces
• Not understanding what Dependent and NormalScope
• Dependent == plain object
• NormalScoped == proxied object
• Bites you when creating custom scopes
JavaOne
@dblevins @tomitribe#EJBCDI
Biggest benefits of CDI
• Very active and open expert group
• Fully extendable
• Beans can be added at runtime
• Fully Open Source
• Spec is open source
• All implementations are open source
• Compliance test (TCK) suite is open source
JavaOne
@dblevins @tomitribe#EJBCDI
What is Aligned?
JavaOne
@dblevins @tomitribe#EJBCDI
Transactions - Aligned
• @TransactionAttribute & @ApplicationException
• Usable by
• @Stateless
• @Stateful
• @Singleton
• @Transactional (CDI equivalent, new in Java EE 7)
JavaOne
@dblevins @tomitribe#EJBCDI
Transaction - EJB flavor
JavaOne
@dblevins @tomitribe#EJBCDI
Transaction - CDI flavor
JavaOne
@dblevins @tomitribe#EJBCDI
Observations
• Pros
• New API is Better
• Doesn’t say “EJB”
• Cons
• Duplicating APIs
• Slight changes
• Conflicting usage?
JavaOne
@dblevins @tomitribe#EJBCDI
Observations - What happens?
• More work for servers to check for mistakes
• More work for IDEs to check for mistakes
• New users won’t know which to use and where
• Old users won’t remember how they are different
• One more place for us all to make mistakes and be confused
JavaOne
@dblevins @tomitribe#EJBCDI
When you still need EJB
(not yet aligned)
JavaOne
@dblevins @tomitribe#EJBCDI
Security
• @RolesAllowed, @PermitAll, @DenyAll
• Usable by
• @Stateless
• @Stateful
• @Singleton
• Alignment
• Low likelihood
• Pandora’s box
• Not actively being discussed
JavaOne
@dblevins @tomitribe#EJBCDI
Startup
• @Startup
• Eagerly creates the instance upon startup
• Usable by
• @Singleton
• Alignment
• Strong Candidate
JavaOne
@dblevins @tomitribe#EJBCDI
Asynchronous
• @Asynchronsous
• Allows method calls to be asynchronous and return Future objects
• Usable by
• @Stateless
• @Stateful
• @Singleton
• Alignment
• Strong Candidate
• Tracked in JIRA, high votes
JavaOne
@dblevins @tomitribe#EJBCDI
Schedule
• @Schedule
• Effectively Cron -- schedule invocations by minute or date, etc.
• Usable by
• @Stateless
• @Singleton
• Not @Stateful
• Alignment
• Strong Candidate
• Could be a challenge -- timers are stateless, scopes are not
JavaOne
@dblevins @tomitribe#EJBCDI
Locking
• @Lock(READ) / @Lock(WRITE) / @AccessTimeout
• Allows for synchronization of methods without complex code
• Usable by
• @Singleton
• Not @Stateless
• Not @Stateful
• Alignment
• Medium Candidate
• Applying to CDI possibly easier than EJB
JavaOne
@dblevins @tomitribe#EJBCDI
MDBs
• @MessageDriven
• Connector-Driven Beans
• Usable by
• Not @Singleton
• Not @Stateless
• Not @Stateful
• Alignment
• Medium Candidate
• Pandora’s Box -- very complicated
JavaOne
@dblevins @tomitribe#EJBCDI
Thank You

Weitere ähnliche Inhalte

Ähnlich wie 2015 JavaOne EJB/CDI Alignment

Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®
Hannes Lowette
 

Ähnlich wie 2015 JavaOne EJB/CDI Alignment (20)

Test-Driven Sitecore
Test-Driven SitecoreTest-Driven Sitecore
Test-Driven Sitecore
 
Mulesoft torronto meetup_16
Mulesoft torronto meetup_16Mulesoft torronto meetup_16
Mulesoft torronto meetup_16
 
Connecting ejb with mule
Connecting ejb with muleConnecting ejb with mule
Connecting ejb with mule
 
codecept.js introduce - front end test E2E tool introduce
codecept.js introduce - front end test E2E tool introducecodecept.js introduce - front end test E2E tool introduce
codecept.js introduce - front end test E2E tool introduce
 
Introduction to node.js
Introduction to node.jsIntroduction to node.js
Introduction to node.js
 
Starting from scratch in 2017
Starting from scratch in 2017Starting from scratch in 2017
Starting from scratch in 2017
 
Enterprise Strength Mobile JavaScript
Enterprise Strength Mobile JavaScriptEnterprise Strength Mobile JavaScript
Enterprise Strength Mobile JavaScript
 
Inside Wordnik's Architecture
Inside Wordnik's ArchitectureInside Wordnik's Architecture
Inside Wordnik's Architecture
 
View controllers: The Right Way
View controllers: The Right WayView controllers: The Right Way
View controllers: The Right Way
 
Java EE Revisits GoF Design Patterns
Java EE Revisits GoF Design PatternsJava EE Revisits GoF Design Patterns
Java EE Revisits GoF Design Patterns
 
Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®
 
Bridging the communication Gap & Continuous Delivery
Bridging the communication Gap & Continuous DeliveryBridging the communication Gap & Continuous Delivery
Bridging the communication Gap & Continuous Delivery
 
Birmingham JUG Lightweight Microservices with Microprofile and Raspberry PIs
Birmingham JUG Lightweight Microservices with Microprofile and Raspberry PIsBirmingham JUG Lightweight Microservices with Microprofile and Raspberry PIs
Birmingham JUG Lightweight Microservices with Microprofile and Raspberry PIs
 
Devoxx UK 2015: How Java EE has changed pattern implementation
Devoxx UK 2015: How Java EE has changed pattern implementationDevoxx UK 2015: How Java EE has changed pattern implementation
Devoxx UK 2015: How Java EE has changed pattern implementation
 
full-stack-webapp-testing-with-selenium-and-rails.pdf
full-stack-webapp-testing-with-selenium-and-rails.pdffull-stack-webapp-testing-with-selenium-and-rails.pdf
full-stack-webapp-testing-with-selenium-and-rails.pdf
 
STP 2014 - Lets Learn from the Top Performance Mistakes in 2013
STP 2014 - Lets Learn from the Top Performance Mistakes in 2013STP 2014 - Lets Learn from the Top Performance Mistakes in 2013
STP 2014 - Lets Learn from the Top Performance Mistakes in 2013
 
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
 
Domain Driven Architecture
Domain Driven ArchitectureDomain Driven Architecture
Domain Driven Architecture
 
Jasmine presentation Selenium Camp 2013
Jasmine presentation Selenium Camp 2013Jasmine presentation Selenium Camp 2013
Jasmine presentation Selenium Camp 2013
 

Kürzlich hochgeladen

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Kürzlich hochgeladen (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

2015 JavaOne EJB/CDI Alignment