The WebSphere Application Server Version 6.1 Feature Pack for EJB 3.0 implements the Enterprise JavaBeans (EJB) Version 3.0 and Java Persistence API (JPA) 1.0 specifications.
Annotations provide component metadata. It is no longer necessary to create Extensible Markup Language (XML) deployment descriptors when you are using annotations.
JIT deployment removes the task of running the ejbdeploy command line tool to generate deployment code as part of development or application installation.
The createEJBStubs command creates stubs for EJB 3.0 specification remote interfaces found in the enterprise beans in a Java archive (JAR) or Enterprise archive (EAR) file.
JPA provides simplified entity persistence. Light-weight domain modeling, including inheritance and polymorphism, is supported.
The JPA specification provides a new persistence framework that is based on successful industry patterns. JPA uses a simple object relational mapping layer on top of a typical Java Database Connectivity (JDBC) resource usage pattern. JPA uses simple JavaBeans classes or Plain Old Java Objects (POJO) to represent relational database content, which is suitable for most Java developers. You can use basic resource access patterns to fetch and store state in the database while using POJO classes instead of JDBC persistence APIs.
The following diagram is an example
of supported functions when a Web application calls a session EJB,
which uses JPA Entities to handle persistence.
Programmatic defaults exist so that you do not need to specify most commonly used requirements in the EJB container. You only need to specify an item if you do not want the default value.
To access the bean's environment easier, a dependency injection function and simpler lookup APIs are introduced. The Web container and application client containers support injection of EJB 3.0 component references using annotations.
POJO development for both business logic and persistence enables unit test outside of the application server, reducing the edit-compile-deploy-debug cycles currently used with applications. It also removes dependencies on external framework interfaces such as javax.ejb.SessionBean, javax.ejb.EJBObject, and so on.
No requirement for session beans to have home interfaces.
Defaulted JNDI name bindings allow many components to be installed without having to specify JNDI name bindings.
AutoLink provides the ability to automatically resolve EJB references to components contained with an EAR file, without having to specify a JNDI binding name. This simplifies application deployment with large numbers of beans and references if they are unique and unambiguous.
To read more about AutoLink, see the topic, EJB 3.0 application bindings overview and the section, Default resolution of EJB references and EJB injections - The Autolink feature.
EJB 3.0 supports application-managed persistence patterns. These patterns use a facade session bean that creates or injects an EntityManagerFactory instance using an @PersistenceUnit annotation during initialization. Each business method that needs to handle persistence uses the EntityManagerFactory instance to create an EntityManager, handle the persistence and close it. This also means that applications must handle passing references to EntityManagers to other classes that need it. This requires a tight coupling between the business methods and the persistence layer, therefore should be avoided.
The following diagram is an example of a typical pattern for using detached JPA entity classes. Detached object patterns allow for data to be read in one transaction and updated in another so that database locks are not held for long periods of time.
This is the typical usage pattern for many
current Web applications. The EJB 3.0 session facade can be either
a stateful or stateless session bean. The session facade uses JPA
EntityManager to handle persistence. It is no longer necessary to
create separate data transfer object classes for communication between
the tiers. The JPA entity POJO classes can serve this purpose.
Container-managed persistence context patterns are also supported. They simplify persistence context reference passing through the use of injection and persistence context propagation. In this case, the container handles the creation of the EntityManagerFactory and EntityManager instances, as well as sharing context with other classes. Container-managed persistence context patterns is the recommended pattern.
The EJB 3.0 specification has simplified session bean development by removing the requirement for a home interface, although you can specify a home interface for client compatability by using a simplified business interface and changing the exception requirements so that they are no longer required to be caught. This removes the requirement of cumbersome JNDI lookup patterns and reduces the metadata management burden through annotations and defaulting.
The EJB 3.0 specification also benefits message-driven beans by simplifying the handling of message listener interfaces.
EJB 2.1-style beans have not changed and are still available. Since there is a need for tooling support to map these beans to database tables, EJB 2.1-style beans should only be contained in a module with an EJB 2.x deployment descriptor and should be isolated from other EJB 3.0 components. Applications that need to take advantage of existing extensions for EJB beans should continue to use EJB 2.1 beans that are packaged in a module with an EJB 2.1 deployment descriptor. This allows the existing assembly tools to manage the extension and binding metadata for those components. The assembly tools can treat this as a legacy module and create the appropriate mappings, bindings and extension information in the EJB 2.1-style beans.
No migration issues are associated with installing the feature pack. Existing applications continue to run and compile without errors. Existing applications can be incrementally enhanced to include the new EJB 3.0 components or existing components incrementally migrated to EJB 3.0 implementation styles. Applications can be extended from pure Java 2 Platform, Enterprise Edition (J2EE) 1.4 style to take advantage of EJB 3.0 and JPA 1.0 specification capabilities seamlessly.
The Feature Pack for EJB 3.0 Samples are available with the installation of the feature pack. These Sample applications use many of the new functions and standards supported in this feature pack. To learn more about these Samples, see the Samples readme located in the app_server_root/samples/src/EJB3SampleApplications/EJB3Counter directory. To learn more about installing the Samples, review the topic Installing EJB 3.0 Samples with the console.
WebSphere Application Server Community Edition 2.0, a productized version of Apache Geronimo, provides sample applications that can be used with the Feature Pack for EJB 3.0, with little or no modification. These samples can be downloaded for free from the WebSphere Application Server Community Edition 2.0 Web site.