Differences between EJB 2.1 and EJB 3.0
Are you preparing for IT certification? With practice questions, study notes, interactive quizzes, tips and technical articles, uCertify PrepKits ensure that you get a solid grasp of core technical concepts to ace your certification exam in first attempt.
Differences between EJB 2.1 and EJB 3.0
Rating:
The Enterprise JavaBeans 3.0 specification is intended to improve the EJB architecture by reducing its complexity from the developer's point of view. There are many differences between the 2.1 and 3.0 versions. The important differences between the two versions are as follows:
| EJB 2.1 enterprise beans | EJB 3.0 enterprise beans |
|---|---|
| An EJB 2.1 session bean must implement the SessionBean interface. | An EJB 3.0 session bean does not implement the SessionBean interface. |
| An EJB 2.1 session bean includes one or more ejbCreate(), ejbPostCreate(), ejbActivate(), ejbPassivate(), ejbRemove(), and setSessionContext(), and the business methods defined in the local/remote interface. | An EJB 3.0 session bean class includes only business methods. |
| EJB 2.1 includes home interface that extends the EjbHome interface, remote interface that extends the javax.ejb.EJBObject interface, local home interface that extends the javax.ejb.EJBLocalHome interface, and local interface that extends the javax.ejb.EJBLocalObject interface. | EJB 3.0 interfaces are POJI (Plain Old Java Interface) business interfaces and do not require home and component interfaces. |
| EJB 2.1 must have the deployment descriptor. | EJB 3.0 may or may not contain deployment descriptors. Annotations are added to the language that can serve almost all the purposes that were previously served by the deployment descriptor. |
| An EJB 2.1 Entity EJB bean class must implement the EntityBean interface and must provide implementation to the ejbCreate() and ejbPostCreate() methods. | EJB 3.0 entities are persistent objects that are not required to implement the EntityBean interface. |
| EJB 2.1 entity bean includes the home, component, local home and local component interfaces that extend the EJBHome, EJBObject, EJBLocalHome and EJBObject interfaces respectively. | EJB 3.0 entities are Plain Old Java Objects (POJO) and do not require home and component interfaces. |
| An EJB 2.1 bean must define resource-ref in ejb-jar.xml to lookup resources. | An EJB 3.0 bean can use either dependency injection or JNDI lookup. |
| An EJB 2.1 message-driven must implement the javax.ejb.MessgeDrivenBean interface. | An EJB 3.0 message-driven may or may not implement the javax.ejb.MessgeDrivenBean interface. |
An enterprise bean that is written to the EJB 2.1 API release may be a client of components written to EJB 3.0 API. Similarily, an enterprise bean that is written for EJB 3.0 API release may be a client of components written to EJB 2.1 API. It is not required to rewrite an enterprise bean written in EJB 2.1 or earlier to support EJB 3.0 beans.
Rating:
Was this information helpful?
Other articles
- What are container-managed transactions?
- What are lifecycle callbacks?
- Things to practice for Sun test CX310-091
- What is the acknowledge mode?
- What is the setFlushMode() method?
