|
The Developer's Resource & Community Site
|
Enterprise JavaBeans Model
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: Enterprise JavaBeans, EJB Server, EJB Containers, EJB Clients.
Pre-required Reading: Enterprise JavaBeans
A basic EJB architecture is shown in the Figure below and consists of:
- An EJB server
- EJB containers that run within the server
- Home objects, Remote EJBObjects and Enterprise Beans that run within containers
- EJB clients
- Auxiliary systems JNDI, JTS and security services
The The Basic Enterprise Java Bean Architecture
Now, let us examine the primary components of the EJB architecture in greater detail:
EJB servers
The EJB server provides an organized framework or execution environment for EJB containers to run in. It makes available system services for multiprocessing, load-balancing, and device access for EJB containers. The EJB server also makes EJB containers running within them visible to the outside world. The EJB server may also provide vendor specific features like an optimized data access interface, additional CORBAServices, SSL support etc. The EJB server is also required to provide JNDI-accessible naming service and transaction management services.
In some respects, the EJB server is analogous to CORBA’s Object Transaction Monitor (OTM). The OTM too provides an execution framework for running server side CORBA components.
EJB containers
An EJB container acts as the interface between an enterprise Bean and low-level, platform-specific functionality that supports the Bean. In essence, the EJB container is an abstraction that manages one or more EJB classes while making the required services available to EJB classes through standard interfaces as defined in the EJB specification. The container vendor is also free to provide additional services implemented at either the container or the server level. An EJB client never accesses a Bean directly. Any Bean access is done through the methods of the container-generated classes, which in turn invoke the Bean's methods.
Having the container interpose on all Bean invocations allows the container to manage transactions, load Bean instances if necessary, and in general to do all the wonderful things that EJBs do.
There are two types of containers: Session containers that may contain transient, non-persistent EJBs whose states are not saved at all and entity containers that contain persistent EJBs whose states are saved between invocations.
The EJB Home interface and Home object
Factory methods for locating, creating and removing instances of EJB classes are defined in the EJB Home interface. The Home object is the implementation of the Home interface. The EJB developer defines the Home interface for his Bean. The EJB container vendor provides tools that automatically generate the implementation code for the home interface defined by the EJB developer.
The Remote interface and EJBObject
The remote interface lists the business methods available for the enterprise Bean. The EJBObject is the client’s view of the enterprise Bean and implements the remote interface. While the enterprise Bean developer defines the remote interface, the container vendor provides the tools necessary to generate the implementation code for the corresponding EJBObject. However, it should be noted that the EJB container is still responsible for managing the EJBObject. Each time the client invokes the EJBObject’s methods, the EJB container first handles the request before delegating it to the enterprise Bean
The Enterprise JavaBean
The real EJB Bean itself is contained within an EJB container, and should never be directly accessed by anyone but the container. Although direct access may be possible, it is inadvisable as that breaks the contract between the Bean and the container
The EJB container should mediate all EJB Bean accesses. For this reason, the EJB Bean developer does not implement the remote interface within the EJB Bean itself. The implementation code for the remote interface is generated automatically by tools that the container vendor provides. This prevents inadvertent direct accesses from clients or other beans
The EJB Clients
EJB clients locate the specific EJB container that contains the enterprise Bean through the Java Naming and Directory Interface (JNDI). They then make use of the EJB container to invoke Bean methods. The EJB client only gets a reference to an EJBObject instance and never really gets a reference to the actual EJB Bean instance itself. When the client invokes a method, the EJBObject receives the request and delegates it to the corresponding Bean instance while providing any necessary wrapping functionality.
The client uses the Home object to locate, create or destroy instances of an EJB class. It uses the EJBObject instance, to invoke the business methods of a Bean
What do you think of this article?
Have your say about the article. You can make your point about the article by mailing [email protected] (If you haven't allready joined, you can join by going to https://www.onelist.com/community/dev-java).
You can also write a review. We will publish the best ones here on this article. Send your review to [email protected]. Please include the title of the article you are reviewing.
Further Reading
The Enterprise JavaBeans Series:
Enterprise Java Beans By Gopalan Suresh Raj.
In this introduction to Enterprise Java Beans, Gopalan covers the bases then goes on to demonstrate how to build server side business object components. This article is the introduction to Gopalans series of Enterprise JavaBeans articles. (This series of articles is courtesy of Gopalan Suresh Raj)
Author: Gopalan Suresh Raj
Date Submitted: January 6th 2000
Level of Difficulty: Advanced
Subjects Covered: Enterprise JavaBeans, EJB Server, EJB Architecture, Java Naming and Directory Interface, Java Transaction Service.
Pre-required Reading: None
Enterprise Java Beans Series - Components at the Server By Gopalan Suresh Raj.
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: Server side components, CORBA
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - EJB Naming Services and JNDI By Gopalan Suresh Raj.
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: Naming Services, Java Naming Directory Interface
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - EJB Transactions and JTS By Gopalan Suresh Raj.
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: Java Transaction Service, Two-phase commits
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - EJB Lifecycle By Gopalan Suresh Raj.
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: EJB server provider, EJB container provider, EJB developer, EJB deployer, Application developer.
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - EJB Servers By Gopalan Suresh Raj.
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: Server Infrastructure
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - EJB Containers By Gopalan Suresh Raj.
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: EJB Containers, EJB Servers
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - EJB Components By Gopalan Suresh Raj.
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: EJB Object, Home Object, Remote Object
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - EJB Session Beans By Gopalan Suresh Raj.
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: Stateful Session Beans, Stateless Session Beans
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - EJB Entity Beans By Gopalan Suresh Raj.
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: Container-Managed Persistence, Bean-Managed Persistence
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - Writing an Entity Bean By Gopalan Suresh Raj.
Part 1 of a four part series: A four tier bank account example
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: Developing Entity Beans, Home & Remote Interfaces, Data Sources.
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - Writing a Session Bean By Gopalan Suresh Raj.
Part 2 of a four part series: A four tier bank account example
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: Developing Session Beans, Home & Remote Interfaces, Deployment Descriptors.
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - Writing an EJB Client By Gopalan Suresh Raj.
Part 3 of a four part series: A four tier bank account example
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: EJB Clients.
Pre-required Reading: Enterprise JavaBeans
Enterprise Java Beans Series - Writing an EJB Servlet Client By Gopalan Suresh Raj.
Part 4 of a four part series: A four tier bank account example
Author: Gopalan Suresh Raj
Date Submitted: January 11th 2000
Level of Difficulty: Advanced
Subjects Covered: Servlet Clients.
Pre-required Reading: Enterprise JavaBeans
Author: Gopalan Suresh Raj
Gopalan has his own site at Author Central (visit him. He also maintains his own site at https://www.execpc.com/~gopalan/) - Contribute to iDevResource.com and you can have one too!
© Copyright 1997-2000 Gopalan Suresh Raj. Reproduced with Permission
|