|
Introduction
The goal of Enterprise
JavaBeans (EJB) 3.0 is to simplify development of Java applications
and standardize the persistence API for the Java platform. EJB 3.0 is
expected to be part of the next major revision of the J2EE platform,
J2EE
5.0. EJB 3.0 is being worked under Java Specification Request 220 (JSR-220)
in the Java Community Process (JCP) and Oracle is a co-lead of the specification.
To date, the JCP has released several draft versions of EJB 3.0
specification against which Oracle has been implementing the EJB 3.0 support in Oracle
Application Server 10g (10.1.3) .
In Oracle
Application Server 10g 10.1.3 Developer Preview 4 , Oracle has implemented most
of the major features of EJB 3.0 Public Draft specification. This
container
is available for download and trial on the Oracle
Technology Network.
The goal of EJB 3.0 Preview features is to provide a vehicle for developers
to try out an early, high quality and complete EJB 3.0 implementation
and determine how well it will meet their requirements as well as to provide
a vehicle for early feedback into the community process.
Key Features in Oracle Application Server 10g (10.1.3) Developer Preview
Simplified API
A key design goal of EJB 3.0 is to simplify the developer experience.
In earlier versions of EJB developers frequently found difficulty working
with extensive APIs and complex deployment descriptors. Oracle
Application Server 10g (10.1.3) Developer Preview provides a full implementation
of the simplified model defined by EJB 3.0 Public Draft.
- Simplified EJB
EJB 3.0 eliminates the need for home and component interfaces and
the requirement for bean classes for implementing javax.ejb.EnterpriseBean
interfaces. The EJB bean class can be a pure Java class often referred
as POJO and the interface can be a simple business interface. The bean
class can implement the business interface.
- Use of Annotations Instead of Deployment Descriptors
Metadata annotation is being used as an alternative to deployment descriptors.
Annotations can be used to specify bean types, different attributes
such as transaction or security settings, O-R mapping and injection
of environment or resource references. Deployment descriptor can be
used to override metadata annotations.
- Dependency Injection
The API for lookup and usage of EJB environment and resource references
is being simplified and dependency injection is being used instead.
Metadata annotation is being used for dependency injection.
- Enhanced Lifecycle Methods and Callback Listener Classes
Unlike previous versions of EJB, the bean developers do not have implement
all unnecessary callback methods but can designate any arbitrary method
as a callback method to receive notifications for life cycle events.
A callback listener class may also be used instead of callback methods
being defined in the same bean class.
- Interceptors
An interceptor is a method that intercepts a business method invocation.
An interceptor method may be defined in a Stateless Session Bean, Stateful
Session Bean or an Message Driven Bean. An interceptor class may also
be used instead of defining the interceptor method in the bean class.
- Simple JNDI lookup of EJB
Lookup of EJB has been simplified and clients do not have to create
a bean instance by invoking create method on EJB and can directly invoke
a method on the EJB.
Session Beans
- Simplified Session Bean
Session Beans are pure Java classes and do not have to implement javax.ejb.SessionBean
interfaces. The home interface is optional. A session bean may either
have a remote, local or both interfaces and these interfaces do not
have to extend EJBObject or EJBLocalObject.
- Metadata Annotations
Metadata annotations are used to specify the bean or interface and
run time properties of session beans. For example, a Session bean is
marked with @Stateless or @Stateful
to specify the bean type. Oracle
Application Server 10.1.3 Developer Preview has comprehensive support of
metadata annotations for session beans as specified in the EJB 3.0 public draft
specification.
- Enhanced Lifecycle methods and call back listeners
Callback listeners are supported with both Stateful and Stateless Session
beans. These callback methods can be either specified using Annotations
or deployment descriptor.
- Dependency Injection
Dependency injection may be used either from a stateful or stateless
session beans. Developers can use either metadata annotations or deployment
descriptors to inject resources, EJB context or environment entries.
- Interceptors
Interceptor methods or interceptor classes are supported with both
Stateful and Stateless session beans.
Message Driven Beans
- Simplified MDB
Message Driven Beans do not have to implement javax.ejb.MessageDriven
interface and they implement javax.jms.MessageListener interface.
- Metadata Annotations
Metadata annotation is used to specify the bean or interface and run
time properties of MDBs. For example, a MDB is marked with @MessageDriven
for specifying the bean type.
- Enhanced Lifecycle Methods and Call Back Listeners
Callback listeners are supported with MDBs. These callback methods
can be either specified using annotations or deployment descriptor.
- Dependency Injection
Dependency injection may be used from an MDB. Developer either use
a metadata annotation or deployment descriptors to inject resources,
EJB context or environment entries used by an MDB.
- Interceptors
Interceptor methods or interceptor classes can be used with MDBs.
Entity Beans/Persistence API
- Simplified Entity Beans (POJO Persistence)
EJB 3.0 greatly simplifies entity beans and standardizes POJO persistence
model. Entity Beans are concrete Java classes and do not require any
interfaces. The entity bean classes support polymorphism and inheritance.
Entities can have different types of relationships and container managed
relationships are manually managed by developers.
- Entity Manager API
EJB 3.0 introduces EntityManager API that is used to create, find,
remove and update entities.
The EntityManager API introduces the concept of detachment/merging
of entity bean instances similar to Value Object Pattern. An bean instance
may be detached and may be updated by a client locally and then sent
back to the EntityManager to be merged/synchronized with the database.
Oracle
Application Server 10.1.3 Developer Preview has comprehensive support of
EntityManager API both inside and outside the EJB container.
- Metadata Annotations
Metadata annotations greatly simplify development of entities by removing
the requirement of deployment descriptors. The Entity annotation is
used to specify a class to be an entity bean. Annotations are used to
specify transaction attributes, security permissions, callback listeners
and annotated queries.
Oracle
Application Server 10.1.3 Developer Preview supports O-R mapping specified
using metadata annotations.
- Query Language Enhancements
EJB 3.0 greatly improves the query capability for entities. It enhances
EJB-QL by additional additional operations such as bulk updates and
deletes, JOIN operations, GROUP BY HAVING, projection and sub-queries.
Also dynamic queries can be written using EJB QL. Oracle
Application Server 10.1.3 Developer Preview supports most enhancements of
query language.
- Enhanced Lifecycle Methods and Call Back Listeners
Callback listeners are supported with entity beans. These callback
methods can be either specified using Annotations or deployment descriptor.
- Usability Outside the Container
The EJB 3.0 persistence engine of Oracle
Application Server 10.1.3 Developer Preview can be used outside
container.
Feature List of EJB 3.0 Available in Oracle Application Server
EJB 3.0 Preview
Session Beans
- POJO bean class - No requirement for implementing javax.ejb.SessionBean interfaces
- POJI interface - No requirement for extending javax.ejb.EJBObject or javax.ejb.EJBLocalObject interfaces
- Optional Home interface
- Metadata Annotations
- Simplified Exception Handling
- Dependency Injection for EJBContext, Resources and environment references
- Enhanced lifecycle methods and call back listener classes
- Interceptor methods and classes
- Step wise migration for EJB 2.1 Session Beans to EJB 3.0
- JDK 1.4 support with XML deployment descriptors
|
Entity Beans
- Light weight persistence model
- No component interfaces
- EntityManager API
- Metadata Annotations for O-R Mapping
- Default Mappings
- Query Language enhancements (Bulk update, named parameter)
- Callback Listeners
- Outside J2EE container
|
Message Driven Beans
- POJO bean class - No requirement for implementing javax.ejb.MessageDriven interfaces
- Metadata Annotations
- Dependency Injection for EJBContext, Resources and environment references
- Enhanced lifecycle methods and call back listener classes
- JDK 1.4 support with XML deployment descriptors
|
|
Top of Page
Summary
EJB 3.0 simplifies the J2EE component programming model and standardizes
POJO persistence model for J2EE. Oracle
Application Server 10g 10.1.3 provides one of the industry's
first comprehensive EJB 3.0 implementations.
|