Getting Started with Enterprise Java Beans (EJB) 3.0 - The difference between EJB 2.1 and EJB 3.0
(Page 2 of 4 )
The changes in EJB 3.0 that influence all of the types of EJB can be divided into three major categories. These include the deployment descriptor, implementing interfaces, and home and remote interfaces. All of these categories make extensive use of annotations, bringing down the use of XML based configuration to the minimum. The following details will make this clearer.
Deployment Descriptor
EJB 2.1 used ejb-jar.xml to specify the EJB name, the bean class name, the interfaces, the finder methods and the container-managed relationships (CMR). Apart from it, a vendor-specific deployment descriptor such as weblogic-ejb-jar.xml, jboss-ejb-jar.xml, and so on was also required to successfully deploy and execute the EJB.
In EJB 3.0 these two deployment descriptors are not required. Instead, meta data annotations are used in the bean class to handle the configurations. Every configuration parameter from bean class name to CMR can be declared using the meta data annotations within the bean class. However, to work with annotations JDK 5.0 is required because only JDK 5.0 can handle the annotations.
Implementing Interfaces
In the EJB 2.1 era, to develop Session and Entity Beans classes implement special interfaces of the javax.ejb package. Session Beans implemented the SessionBean interface and Entity Beans implemented the EntityBean interface. In EJB 3.0, however, Session and Entity Beans are Plain Old Java Objects or POJOs. They do not implement any interfaces.
Home and Remote Interfaces
In EJB 2.1 the home interface extends the javax.ejb.EJBHome interface and the remote interface extends the javax.ejb.EJBObject interface. However, in EJB 3.0 these interfaces are not required. Instead each POJO implements a Plain Old Java Interface or POJI business interface. For example, if a Session Bean is implemented as the HelloWorld POJO, it would implement HelloWorldInterface.
That covers the changes that affect all the types of EJBs. There are changes that are specific to each type that will be discussed in the future. Now that the changes have been introduced, let's see the steps involved in implementing an EJB.
Next: Implementing an EJB Step By Step >>
More Java Articles
More By A.P.Rajshekhar