Core EJB Concepts

Core EJB Concepts

Two key core concepts of the EJB 2.0 specification have been carried over from the EJB 1.0 and EJB 1.1 specifications. They are the component/container architecture, and the EJB runtime deployment architecture.

1 Components and Containers

An EJB is a component that implements business logic in a distributed enterprise application. By a component, we mean that an EJB is a logical concept that is spread across several physical Java classes and interfaces.

An EJB container is where EJBs reside; multiple EJB classes are deployed (or run) within a single EJB container. The EJB container is responsible for making the EJB available to the client—you can't use an EJB without a container. The EJB container provides security, concurrency, and transaction support and memory management (by swapping unused EJBs to secondary storage and by managing a pool of EJB instances). The container is transparent to the client in the respect that the client itself never interacts with it directly; the client only interacts with the container through proxies[1] to the EJB.

[1] As in the Proxy pattern from [Gamma].

2 Deployment

All EJBs are deployed into an EJB container within the context of an EJB-JAR file. Each EJB-JAR file can contain one or more EJBs. The EJB-JAR file consists of the class files that the specification requires the developer write for each EJB, as well as the classes that are generated by the container to support distribution, persistence, transactions, and security. A set of entries in an XML file called a deployment descriptor describe each EJB in an EJB-JAR file and inform the container how to handle details like transaction support and persistence. This XML file is always named ejb-jar.xml and must be located within the META-INF directory of the EJB-JAR file. This structure is shown in Figure.

2. EJB-JAR file structure.


     Python   SQL   Java   php   Perl 
     game development   web development   internet   *nix   graphics   hardware 
     telecommunications   C++ 
     Flash   Active Directory   Windows