EJB3 Feature Overview
The goal of EJB 3.0 is twofold:
1) Simplify the development of Enterprise Java applications
2) Standardize the Java Persistence API.
JBoss views the EJB 3.0 specification as a watershed moment for the simplification of Enterprise Java. Both JBoss Chief Architect Bill Burke and Hibernate Founder Gavin King represent JBoss on the EJB 3.0 (JSR-220) specification team. EJB 3.0 factors heavily into the future of Java Enterprise Edition as well as the JBoss Application Server and Hibernate products. The EJB 3.0 specification team has released several drafts of the EJB 3.0 specification and JBoss has tracked along with these drafts by offering the ability to test drive EJB 3.0 with JBoss Application Server.
EJB 3.0 introduces the following key features:
Simplified EJB API
EJB 3.0 eliminates the need for Home interfaces and for beans to implement required EJB APIs. Session Beans, Message driven Beans, and Entity Beans are now simple Java Beans that are focused on implementing your business logic. Since Entity Beans are now standard Java classes with no onerous interface requirements, this means that Entity Beans can follow object-oriented (O-O) design principles and benefit from inheritance, polymorphism, and other standard O-O constructs.
EJB 3.0 embraces Java Annotations introduced in JDK 5.0. Annotation have been introduced in a way that makes the use of deployment descriptors purely optional. The EJB 3.0 specification defines a wide range of Annotations that cover such things as Bean Types, Dependency Injection, Transaction and Security, Callbacks, Object-Relational Mapping, Relations, etc. Deployment descriptors still have their place for those who want to override Annotations. Both JBoss Application Server and Hibernate support these annotations which means that by using Hibernate, you can get the benefits of EJB 3.0 annotations outside of the EJB 3.0 container and within standalone Java applications.
No more boilerplate code for looking up EJBs and related resources. By introducing the @Inject, @EJB, and @Resource annotations, these dependencies are now injected transparently by the container into your simple Java Beans.
Developers can now just implement the callbacks they are interested in. By using such callback annotations as @PostConstruct, @PreDestroy, @PrePersist, or @PostPersist, developers can map any Java Bean or callback class method to be a callback that receives event notifications.
Entity Manager API
The Entity Manager API is introduced in EJB 3.0 and it is designed to enable Java Bean instances to be detached, updated locally, and then sent back to the EntityManager to be persisted in the database. Both JBoss Application Server and Hibernate support this new API.
Simplified Persistence and Improved Queries
EJB 3.0 standardizes the Java persistence model with Hibernate playing a crucial role in the definition of this API. A full complement of Java Annotations have been defined to handle Object-Relational Mapping and a range of different relation types. EJB 3.0 also enhances EJB-QL with such improvements as support for dynamic queries, subqueries, bulk updates, and bulk deletes.