By: Paul Allen and Joseph Bambara in EJB Tutorials on 2008-08-25
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.
This policy contains information about your privacy. By posting, you are declaring that you understand this policy:
- Your name, rating, website address, town, country, state and comment will be publicly displayed if entered.
- Aside from the data entered into these form fields, other stored data about your comment will include:
- Your IP address (not displayed)
- The time/date of your submission (displayed)
- Your email address will not be shared. It is collected for only two reasons:
- Administrative purposes, should a need to contact you arise.
- To inform you of new comments, should you subscribe to receive notifications.
- A cookie may be set on your computer. This is used to remember your inputs. It will expire by itself.
This policy is subject to change at any time and without notice.
These terms and conditions contain rules about posting comments. By submitting a comment, you are declaring that you agree with these rules:
- Although the administrator will attempt to moderate comments, it is impossible for every comment to have been moderated at any given time.
- You acknowledge that all comments express the views and opinions of the original author and not those of the administrator.
- You agree not to post any material which is knowingly false, obscene, hateful, threatening, harassing or invasive of a person's privacy.
- The administrator has the right to edit, move or remove any comment for any reason and without notice.
Failure to comply with these rules may result in being banned from submitting further comments.
These terms and conditions are subject to change at any time and without notice.
Most Viewed Articles (in EJB )
Latest Articles (in EJB)
- Data Science
- React Native
- Cloud Computing
- Java Beans
- Mac OS X
- Office 365
- Tech Reviews