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.
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
Bean class
Context objects
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.
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.
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.
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.
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:
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:
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 )
Difference Between Stateful and Stateless Session Beans
Difference Between Session and Entity Beans
Required Classes/Interfaces That Must Be Provided for an Enterprise JavaBeans Component
Steps to develop EJB Environment
Latest Articles (in EJB)
© 2023 Java-samples.com
Tutorial Archive: Data Science React Native Android AJAX ASP.net C C++ C# Cocoa Cloud Computing EJB Errors Java Certification Interview iPhone Javascript JSF JSP Java Beans J2ME JDBC Linux Mac OS X MySQL Perl PHP Python Ruby SAP VB.net EJB Struts Trends WebServices XML Office 365 Hibernate
Latest Tutorials on: Data Science React Native Android AJAX ASP.net C Cocoa C++ C# EJB Errors Java Certification Interview iPhone Javascript JSF JSP Java Beans J2ME JDBC Linux Mac OS X MySQL Perl PHP Python Ruby SAP VB.net EJB Struts Cloud Computing WebServices XML Office 365 Hibernate