March 23, 2011, 5:01 p.m.
posted by franni
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 to the EJB.
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.