By: Paul Allen and Joseph Bambara
Here we review the component architecture of EJBs. We also cover the required classes and interfaces for EJB, which include the home and remote interfaces, the XML deployment descriptor, the business logic (bean) class, and the context objects. While these names may or may not be meaningful to you at this point, you will soon understand how each of these pieces fits into the EJB component model.
Classes and Interfaces for EJB
The components used to create and access EJBs facilitate the creation and execution of business logic on an enterprise system. Each EJB session and entity bean must have the following classes and interfaces:
Home (EJBHome) interface
Remote (EJBObject) interface
XML deployment descriptor
Home (EJBHome) Interface
The EJBHome object provides the lifecycle operations (create(), remove(), find()) for an EJB. The containerâ€™s deployment tools generate the class for the EJBHome object. The EJBHome object implements the EJBâ€™s home interface. The client references an EJBHome object to perform lifecycle operations on an EJBObject interface. The Java Naming and Directory Interface (JNDI) is used by the client to locate an EJBHome object.
The EJBHome interface provides access to the beanâ€™s lifecycle services and can be utilized by a client to create or destroy bean instances. For entity beans, it provides finder methods that allow a client to locate an existing bean instance and retrieve it from its persistent data store.
Remote (EJBObject) Interface
The remote (EJBObject) interface provides access to the business methods within the EJB. An EJBObject represents a client view of the EJB. The EJBObject exposes all of the application-related interfaces for the object, but not the interfaces that allow the EJB container to manage and control the object. The EJBObject wrapper allows the EJB container to intercept all operations made on the EJB. Each time a client invokes a method on the EJBObject, the request goes through the EJB container before being delegated to the EJB. The EJB container implements state management, transaction control, security, and persistence services transparently to both the client and the EJB.
XML Deployment Descriptor
The deployment descriptor is an XML (Extensible Markup Language) file provided with each module and application that describes how the parts of a J2EE application should be deployed. The deployment descriptor configures specific container options in your deployment tool of choice.
The rules associated with the EJB that govern lifecycle, transactions, security, and persistence are defined in an associated XML deployment descriptor object. These rules are defined declaratively at the time of deployment rather than programmatically at the time of development. At runtime, the EJB container automatically performs the services according to the values specified in the deployment descriptor object associated with the EJB.
Business Logic (Bean) Class
The bean class is developed by the bean developer and contains the implementation and the methods defined in the remote interface. In other words, the bean class has the basic business logic. For entity and session beans, the bean class extends either javax.ejb.SessionBean or javax.ejb.EntityBean, depending upon the type of EJB required.
Context Objects for Session and Entity
For each active EJB instance, the EJB container generates an instance context object to maintain information about the management rules and the current state of the instance. A session bean uses a SessionContext object, while an entity bean uses an EntityContext object. Both the EJB and the EJB container use the context object to coordinate transactions, security, persistence, and other system services.
1. Too good. Easy to understand , what is the purpose of particular class n interface.Thanks :-)
View Tutorial By: Navneet Kaur at 2012-07-05 09:42:25
Most Viewed Articles (in EJB )
Latest Articles (in EJB)
Comment on this tutorial