Magazine
 
EJB 3.0
 

Introduction To Enterprise Java Bean 3.0 (EJB 3.0)

Enterprise beans are the Java EE server side components that run inside the ejb container and encapsulate the business logic of an enterprise application. Enterprise applications are the software applications developed intended to use at large scale. These applications involve large number of data accessing concurrently by many users. Enterprise beans are used to perform various types of task like interacting with the client, maintaining session for the clients retrieving and holding data from the database and communicating with the server.

The Enterprise JavaBeans specification defines an architecture for a transactional, distributed object system based on server-side components. These server-side components are called enterprise beans or distributed objects that are hosted in Enterprise JavaBean containers where it provide remote services for clients distributed throughout the network.

The EJB Container

An EJB container is nothing but the program that runs on the server and implements the EJB specifications. EJB container provides special type of the environment suitable for running the enterprise components. The EJB container manages remote access to the bean, security, persistence, transactions, concurrency, and access to and pooling of resources. It hosts an enterprise bean in the same manner that the Java Web Server hosts a servlet or an HTML. An enterprise bean can’t perform functions outside of an EJB container.

Migration from EJB2 to EJB3

Migrating to EJB 3.0 is a big step towards simplifying the process of developing EJBs, which reduces lots of complexities, time and cost. In spite of being rich featured, developers feel complex working with previous versions of EJB.

 

Migration from EJB 2.1 to EJB 3.0

Lets go through some points justifying reasons to adopt EJB 3.0 instead of EJB 2.1:

  1. In EJB 2.1, home interface extends the javax.ejb.EJBHome interface and local home interface extends the javax.ejb.EJBLocalHome interface. The EJB 2.1 remote interface extends the javax.ejb.EJBObject interface and local
    interface extends the javax.ejb.EJBLocalObject interface. In EJB 3.0, home and component interfaces are replaced with POJI business interfaces.
  2. EJB 2.1 needs the developer to implement a variety of callback methods in the bean class, like ejbActivate(), ejbPassivate(), ejbLoad(), and ejbStore(), most of which were never used. EJB 3.0 doesn’t force to implement any of these methods and instead can designate any arbitrary
    method as a callback method to receive notifications for life cycle events.
  3. In EJB 2.1, session bean implements the SessionBean interface and entity bean implements the EntityBean interface. In EJB 3.0, session and entity bean classes are POJOs and do not implement the SessionBean and EntityBean interfaces.
  4. The deployment descriptor, which specifies the EJB name, the bean class name, the interfaces, the finder methods etc.is not required because they are replaced by metadata annotations in the bean classes. Annotations are available in JDK 5.0 so you need JDK 5.0 to develop EJB 3.0 EJBs.
  5. In EJB 2.1, client application finds a reference to entity and session bean objects using JNDI name but in EJB 3.0, client finds them using dependency annotations like @Resource, @Inject, and @EJB.
  6. In EJB 2.1, developers used their own way to perform database specific operationslike primary key generation while EJB 3.0 provides support for several databasespecific operations. The O/R mapping model has intrinsic support for native SQL. The O/R mapping is specified using annotations.
  7. . Runtime services like transaction and security are often implemented as the interceptor methods managed by the container. However, in EJB 3.0 developers can write custom interceptor. So developers have control for the actions like committing transaction, security check,
    etc
Jan 2008 | Java Jazz Up |15
 
previous
index
next
 
 
View All Topics
All Pages of this Issue
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,

30
, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 , 54, 55, 56, 57,

58
, 59, 60, 61, 62, 63 , 64, 65 , 66 , 67 , 68 , 69 , 70 , 71 , 72 , 73 , 74 , 75 , 76 , 77 , 78 , 79 , 80 , 81 , 82 ,

83, 84 , 85 , 86, 87 , 88, 89 , 90 , 91 , 92 , 93 , 94 , 95 , 96 , 97 , 98 , 99 , 100 , 101 , 102 , 103, 104 , 105 ,

106, 107,

Download PDF