OverView of EnterPrise JavaBean

Yingzi Song & Hang Yuan

 

What is Enterprise JavaBean?

An EJB is a specialized, non-visual JavaBean that runs on a server. It extends JavaBeans Component Model for Mission Critical Transaction Systems, Endorsed by Leading Enterprise Vendors. It is an API specification for building scalable, distributed, component-based, multi-tier applications. It leverages and extends the JavaBeans component model to provide a rich object-oriented transactional environment for developers building enterprise applications.

Enterprise JavaBeans will make it easy for developers to DEVELOP, DEPLOY and MANAGE enterprise applications by insulating the developer from system level complexity. As a platform-independent Java API, it enables access to existing Transaction Processing Systems.

What is the relationship between Enterprise JavaBeans and JavaBeans?

Enterprise JavaBeans extends the JavaBeans component model to handle the needs of transactional business applications.

JavaBeans is a component model for visual construction reusable components for the Java platform. Enterprise JavaBeans extends JavaBeans to middle-tier/server side business applications. The extensions that Enterprise JavaBeans adds to JavaBeans include support for transactions, state management, and deployment time attributes.

Enterprise JavaBeans architecture specifies how communication among components maps into the underlying communication protocols, such as CORBA/IIOP.

What are Enterprise JavaBeans goals?

EJB is designed to make it easy for developers to create applications, freeing them from low-level system details of managing transactions, threads, load balancing, and so on.Application developers can concentrate on business logic and leave the details of managing the data processing to the framework.

The EJB Specification defines the major structures of the EJB framework, and then specifically defines the contracts between them. The responsibilities of the client, the server, and the individual components are all clearly spelled out.

What are Session Beans and Entity Beans?

A session bean is a transient object that will not live out of  the virtual machine in which it is created. A entity bean is a persistent object that is not limited by the lifetime of the Java virtual machine process in which it is executes. When Java virtual machine crashed, it may result in a rollback of current transaction, but it neither destroys the entity object nor invalidates a reference to it held by clients. So the client can reconnect to the same bean using its object reference.

The differences between session beans and entity beans are:

(1) Session beans only supports a single user. Entity beans can support multiple users.

(2) Session beans can cache data within a transaction. Entity beans can participate in transactions.

(3) Session beans update data in an underlying database. Entity beans represents data in the database.

(4) Session beans is short-lived. It lives as long as its client. Entity beans is long-lived. It lives as long as the data in the database.

(5) Session beans is destroyed when EJB server crashes. Entity beans can survive after a crash of the EJB server.  

(6) Session beans doesn't have a persistent object reference. Entity beans has a persistent object reference.

The EJB Architecture                                                           

EJB Servers                                                                                                (1)Provides naming and transaction services.

(2)Makes containers visible.

(3)Any server that can host an EJB container and provide it with the necessary services can be an EJB server.                                                                                                                             

EJB Clients

(1)Find EJB containers via JNDI.                                                                                            

(2)Make use of EJB beans.                                                                                                          

EJB Containers

(1)Interface between EJB Bean and outside world.                                                                    

(2)Client never accesses bean directly, access is done through container-generated methods which in turn call the beans methods.                                                                                        

(3)Provides services such as transaction and resource management, versioning, scalability, mobility, persistence, and security to the EJB components it contains.                                              

Enterprise Java Beans

(1)Session bean                                                                                                                      

(2)Entity bean                                                                                                                      

Auxiliary Systems

(1)JNDI                                                                                                                                   

(a)Java Naming and Directory Interface.                                                                                   

(b)Used to allow clients to find EJB beans.                                                                                    

(2) JTS                                                                                                                                       

(a)Java Transaction Services.                                                                                                  

(b)Used to provide transaction support in EJB.

                                                   

                          EJB Architecture

                      EJB.gif (10394 bytes)

Reference:

1. Client/Server Programming with Java and CORBA(Second Edition)
    by Robert Orfali & Dan Harkey, 1998
    published by John Wiley & Sons, Inc.

2. Enterprise JavaBeans