SlideShare una empresa de Scribd logo
1 de 43
Descargar para leer sin conexión
EJB and CDI
Alignment and Strategy
Linda DeMichiel
Java EE Specification Lead
Oracle
Java Day Tokyo 2015
April 8, 2015
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Safe Harbor Statement
The following is intended to outline our general product direction. It is intended for
information purposes only, and may not be incorporated into any contract. It is not a
commitment to deliver any material, code, or functionality, and should not be relied upon
in making purchasing decisions. The development, release, and timing of any features or
functionality described for Oracle’s products remains at the sole discretion of Oracle.
4
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
EJB – History, Goals, Evolution
CDI– History, Goals, Evolution
Advantages/disadvantages – when to use EJB/CDI
Java EE – Managed Bean Alignment
What is our strategy for the future
1
2
3
4
5
5
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
EJB
• EJB 1.0 (begun 1996)
– Origins in TP monitors and component-based systems (e.g. Microsoft MTS)
– Designed for remote access and coarse-grained components
• EJB 1.1 (J2EE 1.2)
– First "real" EJB
• EJB 2.0 (J2EE 1.3)
– Updated Entity Beans; EJB QL; Message-driven Beans; IIOP Interoperability
• EJB 2.1 (J2EE 1.4)
– Web services support; Timer service
Some Background and History
6
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
EJB
• EJB 3.0 (Java EE 5)
– First "modern" EJB – Theme is "Ease of Development"
– Annotations; resource injection; simple interfaces; Java Persistence API; interceptors
• EJB 3.1 (Java EE 6)
– No-interface view; asynchronous methods; singletons; EJB Lite; Embedded EJB
– Interceptors separated into own spec; JPA separated into own JSR
• EJB 3.2 (Java EE 7)
– EJB Entity Beans and JAX-RPC now optional
Some Background and History
7
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
EJB Today
• EJBs are POJOs
• Container provides services for ease-of-development
– Injection
– Transactions (declarative with defaults or programmatic)
– Security (declarative with defaults or programmatic)
– Thread management; synchronization; async support
– Timed notifications (declarative or programmatic)
– Integration with JMS, Web Services, IIOP-based clients and services
8
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
EJB – History, Goals, Evolution
CDI– History, Goals, Evolution
Advantages/disadvantages – when to use EJB/CDI
Java EE – Managed Bean Alignment
What is our strategy for the future
1
2
3
4
5
9
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
CDI
• CDI 1.0 (Java EE 6)
– Original goal: direct JSF and EJB integration
– Dependency injection with typed injection points; typesafe resolution
– Annotations, qualifiers, stereotypes for strong typing
– Scopes, contexts for automatic bean lifecycle management
– Producers
– Interceptor bindings; decorators
– Events and observers
– Rich SPI for portable extensions
Some Background and History
10
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
CDI
• CDI 1.1 (Java EE 7)
– Implicit bean archives
– Globally enabled interceptors, decorators, alternatives (with @Priority)
– JTA transactional interceptors; @AroundConstruct interceptors
– Enhancements to SPI and portable extensions
Some Background and History
11
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
CDI Today
• Managed Bean POJOs are central
– @Named qualifier allows direct use in JSF, EL, …
• Container provides services
– Type-safe injection
– Lifecycle management; contexts; scopes; lifecycle callbacks
– Event firing and delivery
– Producers, Alternatives to configure available beans
– Extensible model and rich SPI
12
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
EJB – History, Goals, Evolution
CDI– History, Goals, Evolution
Advantages/disadvantages – when to use EJB/CDI
Java EE – Managed Bean Alignment
What is our strategy for the future
1
2
3
4
5
13
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
CDI Advantages
• Annotation-based programming model; stereotypes
• Type-safe injection, interceptors, decorators
• Context management, scopes, conversations
• Events and observers
• Producers and disposers
• Extensibility
– Custom scopes; programmatically defined beans; etc.
Higher level of abstraction
What does CDI give you that EJB alone does not?
14
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
CDI Advantages
• Automatic context and lifecycle management remove/pooling
• Events+observers callbacks
• Conversations
• Metalevel programming / extensibility
Higher level of abstraction vs EJB
15
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
EJB Advantages
• Remote access
– RMI / CORBA
– Web Services
• MDBs / JMS
• Timers; scheduled events
• Asynchronous methods
• Security intergration
• JPA integration; container-managed extended persistence context
• Locking for concurrent access
What does EJB give you that CDI does not?
16
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
EJB Advantages
• EJBs (session beans) are CDI managed beans
– They have all the benefits of CDI
– Stateless session beans – @Dependent scope
– Stateful session beans – any scope
– Singleton session beans – @ApplicationScoped
– However, need to use @Inject, not @EJB to acquire
• Converse is not true
– CDI beans are not EJBs
– However: We are moving EJB benefits into CDI
What else does EJB give you?
17
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
EJB – History, Goals, Evolution
CDI– History, Goals, Evolution
Advantages/disadvantages – when to use EJB/CDI
Java EE – Managed Bean Alignment
What is our strategy for the future
1
2
3
4
5
18
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
CDI and EJB: Bridging the Gap in Java EE
• @ManagedBean
• Managed Bean spec, introduced in Java EE 6
– Identified commonalities among different components as "managed beans"
– Identified points for extension
• "Managed Bean Alignment" was an important theme of Java EE 7
– Generalize use of injection, interceptors, new scopes
19
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Managed Beans – Java EE 6
20
MATRIX1
Java EE 6
Contextual Support
CDI
injection
into
them
Support
Java EE
Resource
injection
into
them
Injectable
with
@Inject
Injectable
with
@Resource,
@EJB, …
(EE-
defined)
Support
CDI
interceptors
Support EE
interceptors
Support
Decorators
Support
Observer
methods
Can
fire
events
Support
Producer
methods
Can have
Qualifiers
Can
have
Scope
Support
CDI
Constructor
injection
Support
Timers
CDI managed
beans (non-EJBs)
Y Y Y Y Y Y Y(1) Y Y Y Y Y Y Y
Session beans
(CDI-enabled
behavior via
@Inject)
Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y
Java EE
@ManagedBean
beans (CDI-
enabled behavior
via @Inject)
Y Y Y Y Y Y Y Y Y Y Y Y Y Y
Session beans
obtained via
@EJB or JNDI
lookup (with CDI
enabled)
Y Y Y Y Y Y
Java EE
@ManagedBeans
beans obtained
via @Resource or
JNDI lookup
(with CDI
enabled)
Y Y Y Y Y
MDBs Y Y Y Y Y
JAX-RS Resource
classes
Y Y Y
Servlets Y Y Y
Servlet filters,
listeners
Y Y Y
Other Java EE
component
classes (Table EE.
5-1)
Y Y Y
JPA entities
JPA entity
listeners
Y(4) Y
Interceptors Y Y Y
Decorators Y Y Y
Producer
methods
Y(3) Y(5) Y(5) Y Y (2)(3) Y(2)
Producer fields Y(2) Y(2)
Disposer
methods
Y(3) Y(5) Y(5) Y Y(3)
Observer
methods
Y(3) Y(5) Y(5) Y Y(3)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
CDI and EJB: Bridging the Gap in Java EE 7
• CDI is enabled by default in "implicit bean archives"
• Use of CDI bean-defining annotations results in implicit bean archives
– @SessionScoped, @Dependent, …
– Bean archives include library jars, EJB jars, WEB-INF classes, …
– No beans.xml required
Enabling CDI by Default
21
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
CDI and EJB: Bridging the Gap in Java EE 7
• CDI injection applies to all Java EE components when CDI is enabled
• Java EE components support resource injection + CDI injection
– Support for constructor injection added as well
• CDI beans support CDI injection + resource injection
• CDI producers can "transform" resource injection into CDI injection, making
it strongly typed
@Produces @Resource(lookup="java:global/env/jdbc/CustomerDatasource")
@CustomerDatabase DataSource customerDatabase;
Injection
22
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
CDI and EJB: Bridging the Gap in Java EE 7
• CDI interceptor-binding interceptors apply to all Java EE components when
CDI is enabled
• EJBs support "EJB interceptors" + CDI interceptor-binding interceptors
• CDI beans support CDI interceptor-binding interceptors + "EJB
interceptors"
• Java EE components also support both
Interceptors
23
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
JTA Transactional Interceptors
@Inherited
@InterceptorBinding
@Target({TYPE, METHOD}) @Retention(RUNTIME)
public @interface Transactional {
TxType value() default TxType.REQUIRED;
Class[] rollbackOn() default{};
Class[] dontRollbackOn() default{};
}
@Transactional(rollbackOn={SQLException.class},
dontRollbackOn={SQLWarning.class})
public class ShoppingCart {...}
Generalization of Container-managed Transactions (Java EE 7)
24
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Bean Validation Interceptors
@Stateless
public class OrderService {
...
@ValidOrder
public Order placeOrder(
@NotNull String productName,
@Max(10) int quantity,
@NotNull String customerName,
@Address String customerAddress) {
...
}
}
Method-level Validation (Bean Validation 1.1, Java EE 7)
25
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
CDI and EJB: Bridging the Gap in Java EE 7
• CDI Scopes are extensible
– @TransactionScope
• Defined in JTA 1.2
• Used by JMS 2.0
– @FlowScoped (JSF 2.2)
– WebSocket expected to define scope for WebSocket endpoints in Java EE 8
Scopes
26
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Managed Beans – Java EE 7
27
MATRIX
Java EE 7
Contextual Support
CDI
injection
into
them
Support
Java EE
Resource
injection
into
them
Injectable
with
@Inject
Injectable
with
@Resource,
@EJB, …
(EE-
defined)
Support
CDI
interceptors
Support EE
interceptors
(1)
Support
Decorators
Support
Observer
methods
Can
fire
events
Support
Producer
methods
Can have
Qualifiers
Can
have
Scope
Support
CDI
Constructor
injection
Support
Timers
CDI managed
beans (non-EJBs)
Y Y Y Y Y Y Y Y Y Y Y Y Y Y
Session beans
(CDI-enabled
behavior via
@Inject)
Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y
Java EE
@ManagedBean
beans (CDI-
enabled behavior
via @Inject)
Y Y Y Y Y Y Y Y Y Y Y Y Y Y
Session beans
obtained via
@EJB or JNDI
lookup (with CDI
enabled)
Y Y Y Y Y Y Y Y Y
Java EE
@ManagedBeans
beans obtained
via @Resource or
JNDI lookup
(with CDI
enabled)
Y Y Y Y Y Y Y Y
MDBs Y Y Y(6) Y Y Y Y Y
JAX-RS Resource
classes
Y Y Y(6) Y Y Y Y Y
Servlets Y Y Y(6) Y Y Y Y Y
Servlet filters,
listeners
Y Y Y(6) Y Y Y Y Y
Other Java EE
component
classes (Table EE.
5-1)
Y Y Y(6) Y Y Y Y Y
JPA entities Y(6)
JPA entity
listeners (4)
Y Y(6) Y Y Y Y Y
Interceptors Y Y Y(6) Y Y
Decorators Y Y Y Y
Producer
methods
Y(3) Y(5) Y(5) Y Y (2)(3) Y(2)
Producer fields Y(2) Y(2)
Disposer
methods
Y(3) Y(5) Y(5) Y Y(3)
Observer
methods
Y(3) Y(5) Y(5) Y Y(3)
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Program Agenda
EJB – History, Goals, Evolution
CDI– History, Goals, Evolution
Advantages/disadvantages – when to use EJB/CDI
Java EE – Managed Bean Alignment
What is our strategy for the future
1
2
3
4
5
28
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
CDI and EJB: Bridging the Gap in Java EE 8
• Java EE 8 continues the theme of Managed-Bean Alignment
• Container-managed security: authorization
• Message-driven beans
Expanded use of EJB Container Services
29
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Proposed: Authorization via Security Interceptors
@IsAuthorized("hasRoles('Manager') && schedule.officeHrs")
public void transferFunds() {...}
@IsAuthorized("hasRoles('Manager') && hasAttribute('directReports', employee.id)")
public double getSalary(int employeeId) {...}
@IsAuthorized(ruleSourceName="java:app/payrollAuthRules", rule="report")
public void displayReport() {...};
Java EE Security 1.0 (Java EE 8)
30
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Message-driven Beans
• Alternative to EJB message-driven beans
• Usable by any CDI managed bean
• Simpler JMS-specific annotations
• No need for MessageListener implementation
JMS 2.1: New API to receive messages asynchronously (Java EE 8)
31
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Message-driven Beans
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName="connectionFactoryLookup",
propertyValue="jms/myCF"),
@ActivationConfigProperty(propertyName="destinationLookup",
propertyValue="jms/myQueue"),
@ActivationConfigProperty(propertyName="destinationType",
propertyValue="javax.jms/Queue")}
public class MyMDB implements MessageListener {
public void onMessage(Message message) {
// extract message body
String body = message.getBody(String.class));
// process message body
}
}
EJB MDBs Today (Java EE 7)
32
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Proposed: Message-driven Beans
@RequestScoped
public class MyListenerBean {
@JMSListener(destinationLookup="jms/myQueue")
@Transactional
public void myCallback(Message message) {
...
}
}
JMS 2.1 Tomorrow: Allow any Java EE bean to be a listener (Java EE 8)
33
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Bridging the Gap
• JAX-RS Injection alignment
• Parameter injection
• Scope for WebSocket endpoints
• Extension of Timer Service and Timer notifications (@Schedule)
• …
Other Areas of Alignment
34
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Some Gaps Remain
• Java EE components are CDI managed beans
– They can be injected with @Inject
– But, Java EE components other than session beans lose their Java EE
"componentness"
– E.g., you can inject a servlet into a managed bean, but the injected instance won't still
service web requests
35
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Summary
• Java EE 6
– Interceptors
• Java EE 7
– Container-managed transactions transactional interceptors
• Java EE 8
– Container-managed authorization security interceptors
– Message-driven beans simplified messaging with CDI-based MDBs
• Java EE 9
– Timer Service (?)
– Timed Events (?)
– … (?)
EJB Features made more broadly available through CDI
36
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
What is the Future of EJB?
• Part of EJB becoming Optional
– EJB Entity Beans, EJB QL
• Optional as of Java EE 7; superseded by JPA
– Support for JAX-RPC
• Optional as of Java EE 7; superseded by JAX-WS
– IIOP Interoperability ??
• Java EE 8 Experts will decide on "Proposed Optional" status
– Remote interfaces ??
• Java EE 8 Experts will decide on "Proposed Optional" status
– Optionality process is slow
• Takes 2 Java EE Platform release cycles
37
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
What is the Future of EJB?
• Important EJB features are being made more broadly available
– Interceptors, container-managed txs and security, MDBs, …
– Availability is through mechanisms of CDI
• Will EJB still be relevant ?
• EJB's long-term future depends on the future of remaining features
– Remote access (RMI, Web Services)
– @Schedule'd events and Timer Service
– Singletons - @Startup; @DependsOn; container-managed concurrency
– Asynchronous methods
– Integration with JPA
38
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
How You Can Influence the Discussion
• Adopt a JSR
– http://glassfish.org/adoptajsr
• Join an Expert Group project
– http://javaee-spec.java.net
– https://java.net/projects/javaee-spec/pages/Specifications
• The Aquarium
– http://blogs.oracle.com/theaquarium
• Java EE 8 Reference Implementation
– http://glassfish.org
39
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
Safe Harbor Statement
The preceding is intended to outline our general product direction. It is intended for
information purposes only, and may not be incorporated into any contract. It is not a
commitment to deliver any material, code, or functionality, and should not be relied upon
in making purchasing decisions. The development, release, and timing of any features or
functionality described for Oracle’s products remains at the sole discretion of Oracle.
40
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 41
EJB and CDI - Alignment and Strategy
EJB and CDI - Alignment and Strategy

Más contenido relacionado

La actualidad más candente

Christo kutrovsky oracle, memory & linux
Christo kutrovsky   oracle, memory & linuxChristo kutrovsky   oracle, memory & linux
Christo kutrovsky oracle, memory & linux
Kyle Hailey
 

La actualidad más candente (20)

Cassandra Introduction & Features
Cassandra Introduction & FeaturesCassandra Introduction & Features
Cassandra Introduction & Features
 
WebLogic Server Work Managers and Overload Protection
WebLogic Server Work Managers and Overload ProtectionWebLogic Server Work Managers and Overload Protection
WebLogic Server Work Managers and Overload Protection
 
Approximation Data Structures for Streaming Applications
Approximation Data Structures for Streaming ApplicationsApproximation Data Structures for Streaming Applications
Approximation Data Structures for Streaming Applications
 
Ch12 Spring 起步走
Ch12 Spring 起步走Ch12 Spring 起步走
Ch12 Spring 起步走
 
Loom Virtual Threads in the JDK 19
Loom Virtual Threads in the JDK 19Loom Virtual Threads in the JDK 19
Loom Virtual Threads in the JDK 19
 
MAA Best Practices for Oracle Database 19c
MAA Best Practices for Oracle Database 19cMAA Best Practices for Oracle Database 19c
MAA Best Practices for Oracle Database 19c
 
Spring boot Under Da Hood
Spring boot Under Da HoodSpring boot Under Da Hood
Spring boot Under Da Hood
 
How Safe is Asynchronous Master-Master Setup?
 How Safe is Asynchronous Master-Master Setup? How Safe is Asynchronous Master-Master Setup?
How Safe is Asynchronous Master-Master Setup?
 
My First 90 days with Vitess
My First 90 days with VitessMy First 90 days with Vitess
My First 90 days with Vitess
 
"It can always get worse!" – Lessons Learned in over 20 years working with Or...
"It can always get worse!" – Lessons Learned in over 20 years working with Or..."It can always get worse!" – Lessons Learned in over 20 years working with Or...
"It can always get worse!" – Lessons Learned in over 20 years working with Or...
 
HBase HUG Presentation: Avoiding Full GCs with MemStore-Local Allocation Buffers
HBase HUG Presentation: Avoiding Full GCs with MemStore-Local Allocation BuffersHBase HUG Presentation: Avoiding Full GCs with MemStore-Local Allocation Buffers
HBase HUG Presentation: Avoiding Full GCs with MemStore-Local Allocation Buffers
 
MySQL Group Replication
MySQL Group ReplicationMySQL Group Replication
MySQL Group Replication
 
Deploying and Managing Hadoop Clusters with AMBARI
Deploying and Managing Hadoop Clusters with AMBARIDeploying and Managing Hadoop Clusters with AMBARI
Deploying and Managing Hadoop Clusters with AMBARI
 
[네이버오픈소스세미나] Contribution, 전쟁의 서막 : Apache OpenWhisk 성능 개선 - 김동경
[네이버오픈소스세미나] Contribution, 전쟁의 서막 : Apache OpenWhisk 성능 개선 - 김동경[네이버오픈소스세미나] Contribution, 전쟁의 서막 : Apache OpenWhisk 성능 개선 - 김동경
[네이버오픈소스세미나] Contribution, 전쟁의 서막 : Apache OpenWhisk 성능 개선 - 김동경
 
Node Labels in YARN
Node Labels in YARNNode Labels in YARN
Node Labels in YARN
 
Benchmarking Apache Druid
Benchmarking Apache Druid Benchmarking Apache Druid
Benchmarking Apache Druid
 
Enabling Vectorized Engine in Apache Spark
Enabling Vectorized Engine in Apache SparkEnabling Vectorized Engine in Apache Spark
Enabling Vectorized Engine in Apache Spark
 
Christo kutrovsky oracle, memory & linux
Christo kutrovsky   oracle, memory & linuxChristo kutrovsky   oracle, memory & linux
Christo kutrovsky oracle, memory & linux
 
Custom PrimeFaces components
Custom PrimeFaces componentsCustom PrimeFaces components
Custom PrimeFaces components
 
Developing Kafka Streams Applications with Upgradability in Mind with Neil Bu...
Developing Kafka Streams Applications with Upgradability in Mind with Neil Bu...Developing Kafka Streams Applications with Upgradability in Mind with Neil Bu...
Developing Kafka Streams Applications with Upgradability in Mind with Neil Bu...
 

Destacado

Solaris 11 Consolidation Tools
Solaris 11 Consolidation ToolsSolaris 11 Consolidation Tools
Solaris 11 Consolidation Tools
Roman Ivanov
 
EJB 3.1 by Bert Ertman
EJB 3.1 by Bert ErtmanEJB 3.1 by Bert Ertman
EJB 3.1 by Bert Ertman
Stephan Janssen
 

Destacado (20)

2015 JavaOne EJB/CDI Alignment
2015 JavaOne EJB/CDI Alignment2015 JavaOne EJB/CDI Alignment
2015 JavaOne EJB/CDI Alignment
 
Servlet 4.0 at GeekOut 2015
Servlet 4.0 at GeekOut 2015Servlet 4.0 at GeekOut 2015
Servlet 4.0 at GeekOut 2015
 
Top 50 java ee 7 best practices [con5669]
Top 50 java ee 7 best practices [con5669]Top 50 java ee 7 best practices [con5669]
Top 50 java ee 7 best practices [con5669]
 
Dependency injection for beginners
Dependency injection for beginnersDependency injection for beginners
Dependency injection for beginners
 
Solaris 11 Consolidation Tools
Solaris 11 Consolidation ToolsSolaris 11 Consolidation Tools
Solaris 11 Consolidation Tools
 
Oracle RAC 25年の進化
Oracle RAC 25年の進化Oracle RAC 25年の進化
Oracle RAC 25年の進化
 
Business Strategy & Alignment to Project Management
Business Strategy & Alignment to Project ManagementBusiness Strategy & Alignment to Project Management
Business Strategy & Alignment to Project Management
 
Java EE 7: Developing for the Cloud at Geecon, JEEConf, Johannesburg
Java EE 7: Developing for the Cloud at Geecon, JEEConf, JohannesburgJava EE 7: Developing for the Cloud at Geecon, JEEConf, Johannesburg
Java EE 7: Developing for the Cloud at Geecon, JEEConf, Johannesburg
 
Ejb3 Presentation
Ejb3 PresentationEjb3 Presentation
Ejb3 Presentation
 
Dependency injection - the right way
Dependency injection - the right wayDependency injection - the right way
Dependency injection - the right way
 
Batching and Java EE (jdk.io)
Batching and Java EE (jdk.io)Batching and Java EE (jdk.io)
Batching and Java EE (jdk.io)
 
JetBrains IDEハンズオン
JetBrains IDEハンズオンJetBrains IDEハンズオン
JetBrains IDEハンズオン
 
Designing JEE Application Structure
Designing JEE Application StructureDesigning JEE Application Structure
Designing JEE Application Structure
 
EJB 3.1 by Bert Ertman
EJB 3.1 by Bert ErtmanEJB 3.1 by Bert Ertman
EJB 3.1 by Bert Ertman
 
Enterprise Java Beans 3 - Business Logic
Enterprise Java Beans 3 - Business LogicEnterprise Java Beans 3 - Business Logic
Enterprise Java Beans 3 - Business Logic
 
Java EE 7 for Real Enterprise Systems
Java EE 7 for Real Enterprise SystemsJava EE 7 for Real Enterprise Systems
Java EE 7 for Real Enterprise Systems
 
Curso Java Avanzado 5 Ejb
Curso Java Avanzado   5 EjbCurso Java Avanzado   5 Ejb
Curso Java Avanzado 5 Ejb
 
Java ee 8 + security overview
Java ee 8 + security overviewJava ee 8 + security overview
Java ee 8 + security overview
 
Java EE Pattern: The Boundary Layer
Java EE Pattern: The Boundary LayerJava EE Pattern: The Boundary Layer
Java EE Pattern: The Boundary Layer
 
Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)
Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)
Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)
 

Similar a EJB and CDI - Alignment and Strategy

Oracle WebLogic Server 12.2.1 Do More with Less
Oracle WebLogic Server 12.2.1 Do More with LessOracle WebLogic Server 12.2.1 Do More with Less
Oracle WebLogic Server 12.2.1 Do More with Less
Ed Burns
 

Similar a EJB and CDI - Alignment and Strategy (20)

Java EE 6 Live Hacking - Java Developer Day 2012
Java EE 6 Live Hacking - Java Developer Day 2012Java EE 6 Live Hacking - Java Developer Day 2012
Java EE 6 Live Hacking - Java Developer Day 2012
 
MVC 1.0 / JSR 371
MVC 1.0 / JSR 371MVC 1.0 / JSR 371
MVC 1.0 / JSR 371
 
JSF 2.3 Adopt-a-JSR 10 Minute Infodeck
JSF 2.3 Adopt-a-JSR 10 Minute InfodeckJSF 2.3 Adopt-a-JSR 10 Minute Infodeck
JSF 2.3 Adopt-a-JSR 10 Minute Infodeck
 
Oracle JET overview
Oracle JET overviewOracle JET overview
Oracle JET overview
 
Burns jsf-confess-2015
Burns jsf-confess-2015Burns jsf-confess-2015
Burns jsf-confess-2015
 
How to Thrive on REST/WebSocket-Based Microservices
How to Thrive on REST/WebSocket-Based MicroservicesHow to Thrive on REST/WebSocket-Based Microservices
How to Thrive on REST/WebSocket-Based Microservices
 
JDK versions and OpenJDK
JDK versions and OpenJDKJDK versions and OpenJDK
JDK versions and OpenJDK
 
JDK 10 Java Module System
JDK 10 Java Module SystemJDK 10 Java Module System
JDK 10 Java Module System
 
Mastering DevOps with Oracle
Mastering DevOps with Oracle Mastering DevOps with Oracle
Mastering DevOps with Oracle
 
JavaOne2015報告会 in Okinawa
JavaOne2015報告会 in OkinawaJavaOne2015報告会 in Okinawa
JavaOne2015報告会 in Okinawa
 
Increased Developer Productivity for IoT with Java and Reactive Blocks (Oracl...
Increased Developer Productivity for IoT with Java and Reactive Blocks (Oracl...Increased Developer Productivity for IoT with Java and Reactive Blocks (Oracl...
Increased Developer Productivity for IoT with Java and Reactive Blocks (Oracl...
 
EJB 3.2 - Java EE 7 - Java One Hyderabad 2012
EJB 3.2 - Java EE 7 - Java One Hyderabad 2012EJB 3.2 - Java EE 7 - Java One Hyderabad 2012
EJB 3.2 - Java EE 7 - Java One Hyderabad 2012
 
Testing Java EE Applications Using Arquillian
Testing Java EE Applications Using ArquillianTesting Java EE Applications Using Arquillian
Testing Java EE Applications Using Arquillian
 
Oracle WebLogic Server 12.2.1 Do More with Less
Oracle WebLogic Server 12.2.1 Do More with LessOracle WebLogic Server 12.2.1 Do More with Less
Oracle WebLogic Server 12.2.1 Do More with Less
 
Serverless Java - Challenges and Triumphs
Serverless Java - Challenges and TriumphsServerless Java - Challenges and Triumphs
Serverless Java - Challenges and Triumphs
 
Java SE Subscription Workshop
Java SE Subscription WorkshopJava SE Subscription Workshop
Java SE Subscription Workshop
 
Melhore o Desenvolvimento do Time com DevOps na Nuvem
Melhore o Desenvolvimento do Time com DevOps na NuvemMelhore o Desenvolvimento do Time com DevOps na Nuvem
Melhore o Desenvolvimento do Time com DevOps na Nuvem
 
Turning Relational Database Tables into Hadoop Datasources by Kuassi Mensah
Turning Relational Database Tables into Hadoop Datasources by Kuassi MensahTurning Relational Database Tables into Hadoop Datasources by Kuassi Mensah
Turning Relational Database Tables into Hadoop Datasources by Kuassi Mensah
 
Full Speed Ahead! (Ahead-of-Time Compilation for Java SE) [JavaOne 2017 CON3738]
Full Speed Ahead! (Ahead-of-Time Compilation for Java SE) [JavaOne 2017 CON3738]Full Speed Ahead! (Ahead-of-Time Compilation for Java SE) [JavaOne 2017 CON3738]
Full Speed Ahead! (Ahead-of-Time Compilation for Java SE) [JavaOne 2017 CON3738]
 
OOW15 - Oracle Enterprise Manager Cloud Control for Managing Oracle E-Busines...
OOW15 - Oracle Enterprise Manager Cloud Control for Managing Oracle E-Busines...OOW15 - Oracle Enterprise Manager Cloud Control for Managing Oracle E-Busines...
OOW15 - Oracle Enterprise Manager Cloud Control for Managing Oracle E-Busines...
 

Más de David Delabassee

Más de David Delabassee (20)

JVMs in Containers - Best Practices
JVMs in Containers - Best PracticesJVMs in Containers - Best Practices
JVMs in Containers - Best Practices
 
JVMs in Containers
JVMs in ContainersJVMs in Containers
JVMs in Containers
 
Serverless Java Challenges & Triumphs
Serverless Java Challenges & TriumphsServerless Java Challenges & Triumphs
Serverless Java Challenges & Triumphs
 
Randstad Docker meetup - Serverless
Randstad Docker meetup - ServerlessRandstad Docker meetup - Serverless
Randstad Docker meetup - Serverless
 
Java Serverless in Action - Voxxed Banff
Java Serverless in Action - Voxxed BanffJava Serverless in Action - Voxxed Banff
Java Serverless in Action - Voxxed Banff
 
Serverless Kotlin
Serverless KotlinServerless Kotlin
Serverless Kotlin
 
REST in an Async World
REST in an Async WorldREST in an Async World
REST in an Async World
 
JAX-RS 2.1 Reloaded
JAX-RS 2.1 ReloadedJAX-RS 2.1 Reloaded
JAX-RS 2.1 Reloaded
 
Java EE 8 - February 2017 update
Java EE 8 - February 2017 updateJava EE 8 - February 2017 update
Java EE 8 - February 2017 update
 
Java EE Next
Java EE NextJava EE Next
Java EE Next
 
Java EE Next - BeJUG JavaOne Afterglow 2016
Java EE Next - BeJUG JavaOne Afterglow 2016Java EE Next - BeJUG JavaOne Afterglow 2016
Java EE Next - BeJUG JavaOne Afterglow 2016
 
HTTP/2 comes to Java
HTTP/2 comes to JavaHTTP/2 comes to Java
HTTP/2 comes to Java
 
Java EE 8 - Work in progress
Java EE 8 - Work in progressJava EE 8 - Work in progress
Java EE 8 - Work in progress
 
HTTP/2 comes to Java (Dec. 2015 version)
HTTP/2 comes to Java (Dec. 2015 version)HTTP/2 comes to Java (Dec. 2015 version)
HTTP/2 comes to Java (Dec. 2015 version)
 
HTTP/2 Comes to Java
HTTP/2 Comes to JavaHTTP/2 Comes to Java
HTTP/2 Comes to Java
 
Java EE 8 - What’s new on the Web front
Java EE 8 - What’s new on the Web frontJava EE 8 - What’s new on the Web front
Java EE 8 - What’s new on the Web front
 
HTTP/2 Comes to Java
HTTP/2 Comes to JavaHTTP/2 Comes to Java
HTTP/2 Comes to Java
 
What's coming in Java EE 8
What's coming in Java EE 8What's coming in Java EE 8
What's coming in Java EE 8
 
Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0
Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0
Java EE 8 Adopt a JSR : JSON-P 1.1 & MVC 1.0
 
Java EE 8 - An instant snapshot
Java EE 8 - An instant snapshot Java EE 8 - An instant snapshot
Java EE 8 - An instant snapshot
 

Último

( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
nilamkumrai
 

Último (20)

Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
 
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
 
Enjoy Night⚡Call Girls Samalka Delhi >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Samalka Delhi >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Samalka Delhi >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Samalka Delhi >༒8448380779 Escort Service
 
VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53
 
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls DubaiDubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
 
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
 
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
Ganeshkhind ! Call Girls Pune - 450+ Call Girl Cash Payment 8005736733 Neha T...
 
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
 
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
 
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
 
Al Barsha Night Partner +0567686026 Call Girls Dubai
Al Barsha Night Partner +0567686026 Call Girls  DubaiAl Barsha Night Partner +0567686026 Call Girls  Dubai
Al Barsha Night Partner +0567686026 Call Girls Dubai
 
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
 
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
 
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
 
Real Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts ServiceReal Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts Service
 
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
 
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
 

EJB and CDI - Alignment and Strategy

  • 1.
  • 2.
  • 3. EJB and CDI Alignment and Strategy Linda DeMichiel Java EE Specification Lead Oracle Java Day Tokyo 2015 April 8, 2015 Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
  • 4. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. 4
  • 5. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Program Agenda EJB – History, Goals, Evolution CDI– History, Goals, Evolution Advantages/disadvantages – when to use EJB/CDI Java EE – Managed Bean Alignment What is our strategy for the future 1 2 3 4 5 5
  • 6. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | EJB • EJB 1.0 (begun 1996) – Origins in TP monitors and component-based systems (e.g. Microsoft MTS) – Designed for remote access and coarse-grained components • EJB 1.1 (J2EE 1.2) – First "real" EJB • EJB 2.0 (J2EE 1.3) – Updated Entity Beans; EJB QL; Message-driven Beans; IIOP Interoperability • EJB 2.1 (J2EE 1.4) – Web services support; Timer service Some Background and History 6
  • 7. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | EJB • EJB 3.0 (Java EE 5) – First "modern" EJB – Theme is "Ease of Development" – Annotations; resource injection; simple interfaces; Java Persistence API; interceptors • EJB 3.1 (Java EE 6) – No-interface view; asynchronous methods; singletons; EJB Lite; Embedded EJB – Interceptors separated into own spec; JPA separated into own JSR • EJB 3.2 (Java EE 7) – EJB Entity Beans and JAX-RPC now optional Some Background and History 7
  • 8. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | EJB Today • EJBs are POJOs • Container provides services for ease-of-development – Injection – Transactions (declarative with defaults or programmatic) – Security (declarative with defaults or programmatic) – Thread management; synchronization; async support – Timed notifications (declarative or programmatic) – Integration with JMS, Web Services, IIOP-based clients and services 8
  • 9. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Program Agenda EJB – History, Goals, Evolution CDI– History, Goals, Evolution Advantages/disadvantages – when to use EJB/CDI Java EE – Managed Bean Alignment What is our strategy for the future 1 2 3 4 5 9
  • 10. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | CDI • CDI 1.0 (Java EE 6) – Original goal: direct JSF and EJB integration – Dependency injection with typed injection points; typesafe resolution – Annotations, qualifiers, stereotypes for strong typing – Scopes, contexts for automatic bean lifecycle management – Producers – Interceptor bindings; decorators – Events and observers – Rich SPI for portable extensions Some Background and History 10
  • 11. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | CDI • CDI 1.1 (Java EE 7) – Implicit bean archives – Globally enabled interceptors, decorators, alternatives (with @Priority) – JTA transactional interceptors; @AroundConstruct interceptors – Enhancements to SPI and portable extensions Some Background and History 11
  • 12. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | CDI Today • Managed Bean POJOs are central – @Named qualifier allows direct use in JSF, EL, … • Container provides services – Type-safe injection – Lifecycle management; contexts; scopes; lifecycle callbacks – Event firing and delivery – Producers, Alternatives to configure available beans – Extensible model and rich SPI 12
  • 13. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Program Agenda EJB – History, Goals, Evolution CDI– History, Goals, Evolution Advantages/disadvantages – when to use EJB/CDI Java EE – Managed Bean Alignment What is our strategy for the future 1 2 3 4 5 13
  • 14. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | CDI Advantages • Annotation-based programming model; stereotypes • Type-safe injection, interceptors, decorators • Context management, scopes, conversations • Events and observers • Producers and disposers • Extensibility – Custom scopes; programmatically defined beans; etc. Higher level of abstraction What does CDI give you that EJB alone does not? 14
  • 15. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | CDI Advantages • Automatic context and lifecycle management remove/pooling • Events+observers callbacks • Conversations • Metalevel programming / extensibility Higher level of abstraction vs EJB 15
  • 16. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | EJB Advantages • Remote access – RMI / CORBA – Web Services • MDBs / JMS • Timers; scheduled events • Asynchronous methods • Security intergration • JPA integration; container-managed extended persistence context • Locking for concurrent access What does EJB give you that CDI does not? 16
  • 17. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | EJB Advantages • EJBs (session beans) are CDI managed beans – They have all the benefits of CDI – Stateless session beans – @Dependent scope – Stateful session beans – any scope – Singleton session beans – @ApplicationScoped – However, need to use @Inject, not @EJB to acquire • Converse is not true – CDI beans are not EJBs – However: We are moving EJB benefits into CDI What else does EJB give you? 17
  • 18. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Program Agenda EJB – History, Goals, Evolution CDI– History, Goals, Evolution Advantages/disadvantages – when to use EJB/CDI Java EE – Managed Bean Alignment What is our strategy for the future 1 2 3 4 5 18
  • 19. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | CDI and EJB: Bridging the Gap in Java EE • @ManagedBean • Managed Bean spec, introduced in Java EE 6 – Identified commonalities among different components as "managed beans" – Identified points for extension • "Managed Bean Alignment" was an important theme of Java EE 7 – Generalize use of injection, interceptors, new scopes 19
  • 20. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Managed Beans – Java EE 6 20 MATRIX1 Java EE 6 Contextual Support CDI injection into them Support Java EE Resource injection into them Injectable with @Inject Injectable with @Resource, @EJB, … (EE- defined) Support CDI interceptors Support EE interceptors Support Decorators Support Observer methods Can fire events Support Producer methods Can have Qualifiers Can have Scope Support CDI Constructor injection Support Timers CDI managed beans (non-EJBs) Y Y Y Y Y Y Y(1) Y Y Y Y Y Y Y Session beans (CDI-enabled behavior via @Inject) Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Java EE @ManagedBean beans (CDI- enabled behavior via @Inject) Y Y Y Y Y Y Y Y Y Y Y Y Y Y Session beans obtained via @EJB or JNDI lookup (with CDI enabled) Y Y Y Y Y Y Java EE @ManagedBeans beans obtained via @Resource or JNDI lookup (with CDI enabled) Y Y Y Y Y MDBs Y Y Y Y Y JAX-RS Resource classes Y Y Y Servlets Y Y Y Servlet filters, listeners Y Y Y Other Java EE component classes (Table EE. 5-1) Y Y Y JPA entities JPA entity listeners Y(4) Y Interceptors Y Y Y Decorators Y Y Y Producer methods Y(3) Y(5) Y(5) Y Y (2)(3) Y(2) Producer fields Y(2) Y(2) Disposer methods Y(3) Y(5) Y(5) Y Y(3) Observer methods Y(3) Y(5) Y(5) Y Y(3)
  • 21. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | CDI and EJB: Bridging the Gap in Java EE 7 • CDI is enabled by default in "implicit bean archives" • Use of CDI bean-defining annotations results in implicit bean archives – @SessionScoped, @Dependent, … – Bean archives include library jars, EJB jars, WEB-INF classes, … – No beans.xml required Enabling CDI by Default 21
  • 22. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | CDI and EJB: Bridging the Gap in Java EE 7 • CDI injection applies to all Java EE components when CDI is enabled • Java EE components support resource injection + CDI injection – Support for constructor injection added as well • CDI beans support CDI injection + resource injection • CDI producers can "transform" resource injection into CDI injection, making it strongly typed @Produces @Resource(lookup="java:global/env/jdbc/CustomerDatasource") @CustomerDatabase DataSource customerDatabase; Injection 22
  • 23. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | CDI and EJB: Bridging the Gap in Java EE 7 • CDI interceptor-binding interceptors apply to all Java EE components when CDI is enabled • EJBs support "EJB interceptors" + CDI interceptor-binding interceptors • CDI beans support CDI interceptor-binding interceptors + "EJB interceptors" • Java EE components also support both Interceptors 23
  • 24. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | JTA Transactional Interceptors @Inherited @InterceptorBinding @Target({TYPE, METHOD}) @Retention(RUNTIME) public @interface Transactional { TxType value() default TxType.REQUIRED; Class[] rollbackOn() default{}; Class[] dontRollbackOn() default{}; } @Transactional(rollbackOn={SQLException.class}, dontRollbackOn={SQLWarning.class}) public class ShoppingCart {...} Generalization of Container-managed Transactions (Java EE 7) 24
  • 25. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Bean Validation Interceptors @Stateless public class OrderService { ... @ValidOrder public Order placeOrder( @NotNull String productName, @Max(10) int quantity, @NotNull String customerName, @Address String customerAddress) { ... } } Method-level Validation (Bean Validation 1.1, Java EE 7) 25
  • 26. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | CDI and EJB: Bridging the Gap in Java EE 7 • CDI Scopes are extensible – @TransactionScope • Defined in JTA 1.2 • Used by JMS 2.0 – @FlowScoped (JSF 2.2) – WebSocket expected to define scope for WebSocket endpoints in Java EE 8 Scopes 26
  • 27. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Managed Beans – Java EE 7 27 MATRIX Java EE 7 Contextual Support CDI injection into them Support Java EE Resource injection into them Injectable with @Inject Injectable with @Resource, @EJB, … (EE- defined) Support CDI interceptors Support EE interceptors (1) Support Decorators Support Observer methods Can fire events Support Producer methods Can have Qualifiers Can have Scope Support CDI Constructor injection Support Timers CDI managed beans (non-EJBs) Y Y Y Y Y Y Y Y Y Y Y Y Y Y Session beans (CDI-enabled behavior via @Inject) Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Java EE @ManagedBean beans (CDI- enabled behavior via @Inject) Y Y Y Y Y Y Y Y Y Y Y Y Y Y Session beans obtained via @EJB or JNDI lookup (with CDI enabled) Y Y Y Y Y Y Y Y Y Java EE @ManagedBeans beans obtained via @Resource or JNDI lookup (with CDI enabled) Y Y Y Y Y Y Y Y MDBs Y Y Y(6) Y Y Y Y Y JAX-RS Resource classes Y Y Y(6) Y Y Y Y Y Servlets Y Y Y(6) Y Y Y Y Y Servlet filters, listeners Y Y Y(6) Y Y Y Y Y Other Java EE component classes (Table EE. 5-1) Y Y Y(6) Y Y Y Y Y JPA entities Y(6) JPA entity listeners (4) Y Y(6) Y Y Y Y Y Interceptors Y Y Y(6) Y Y Decorators Y Y Y Y Producer methods Y(3) Y(5) Y(5) Y Y (2)(3) Y(2) Producer fields Y(2) Y(2) Disposer methods Y(3) Y(5) Y(5) Y Y(3) Observer methods Y(3) Y(5) Y(5) Y Y(3)
  • 28. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Program Agenda EJB – History, Goals, Evolution CDI– History, Goals, Evolution Advantages/disadvantages – when to use EJB/CDI Java EE – Managed Bean Alignment What is our strategy for the future 1 2 3 4 5 28
  • 29. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | CDI and EJB: Bridging the Gap in Java EE 8 • Java EE 8 continues the theme of Managed-Bean Alignment • Container-managed security: authorization • Message-driven beans Expanded use of EJB Container Services 29
  • 30. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Proposed: Authorization via Security Interceptors @IsAuthorized("hasRoles('Manager') && schedule.officeHrs") public void transferFunds() {...} @IsAuthorized("hasRoles('Manager') && hasAttribute('directReports', employee.id)") public double getSalary(int employeeId) {...} @IsAuthorized(ruleSourceName="java:app/payrollAuthRules", rule="report") public void displayReport() {...}; Java EE Security 1.0 (Java EE 8) 30
  • 31. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Message-driven Beans • Alternative to EJB message-driven beans • Usable by any CDI managed bean • Simpler JMS-specific annotations • No need for MessageListener implementation JMS 2.1: New API to receive messages asynchronously (Java EE 8) 31
  • 32. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Message-driven Beans @MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName="connectionFactoryLookup", propertyValue="jms/myCF"), @ActivationConfigProperty(propertyName="destinationLookup", propertyValue="jms/myQueue"), @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms/Queue")} public class MyMDB implements MessageListener { public void onMessage(Message message) { // extract message body String body = message.getBody(String.class)); // process message body } } EJB MDBs Today (Java EE 7) 32
  • 33. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Proposed: Message-driven Beans @RequestScoped public class MyListenerBean { @JMSListener(destinationLookup="jms/myQueue") @Transactional public void myCallback(Message message) { ... } } JMS 2.1 Tomorrow: Allow any Java EE bean to be a listener (Java EE 8) 33
  • 34. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Bridging the Gap • JAX-RS Injection alignment • Parameter injection • Scope for WebSocket endpoints • Extension of Timer Service and Timer notifications (@Schedule) • … Other Areas of Alignment 34
  • 35. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Some Gaps Remain • Java EE components are CDI managed beans – They can be injected with @Inject – But, Java EE components other than session beans lose their Java EE "componentness" – E.g., you can inject a servlet into a managed bean, but the injected instance won't still service web requests 35
  • 36. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Summary • Java EE 6 – Interceptors • Java EE 7 – Container-managed transactions transactional interceptors • Java EE 8 – Container-managed authorization security interceptors – Message-driven beans simplified messaging with CDI-based MDBs • Java EE 9 – Timer Service (?) – Timed Events (?) – … (?) EJB Features made more broadly available through CDI 36
  • 37. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | What is the Future of EJB? • Part of EJB becoming Optional – EJB Entity Beans, EJB QL • Optional as of Java EE 7; superseded by JPA – Support for JAX-RPC • Optional as of Java EE 7; superseded by JAX-WS – IIOP Interoperability ?? • Java EE 8 Experts will decide on "Proposed Optional" status – Remote interfaces ?? • Java EE 8 Experts will decide on "Proposed Optional" status – Optionality process is slow • Takes 2 Java EE Platform release cycles 37
  • 38. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | What is the Future of EJB? • Important EJB features are being made more broadly available – Interceptors, container-managed txs and security, MDBs, … – Availability is through mechanisms of CDI • Will EJB still be relevant ? • EJB's long-term future depends on the future of remaining features – Remote access (RMI, Web Services) – @Schedule'd events and Timer Service – Singletons - @Startup; @DependsOn; container-managed concurrency – Asynchronous methods – Integration with JPA 38
  • 39. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | How You Can Influence the Discussion • Adopt a JSR – http://glassfish.org/adoptajsr • Join an Expert Group project – http://javaee-spec.java.net – https://java.net/projects/javaee-spec/pages/Specifications • The Aquarium – http://blogs.oracle.com/theaquarium • Java EE 8 Reference Implementation – http://glassfish.org 39
  • 40. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The preceding is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. 40
  • 41. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | 41