ARCHITECTURE OF AN EJB/ CLIENT SYSTEM
There are various architectures of EJB (J2EE) available which are used for various
purposes. J2EE is a standard architecture specifically oriented to the development and
deployment of enterprise Web-oriented applications that use Java programming language.purposes. J2EE is a standard architecture specifically oriented to the development and
ISVs and enterprises can use the J2EE architecture for only not the development and
deployment of intranet applications, thus effectively replacing the two-tier and three-tier
models, but also for the development of Internet applications, effectively replacing the
cgi-bin-based approach. The J2EE architecture provides a flexible distribution and tiering
model that allows enterprises to construct their applications in the most suitable manner.
Now, let us understand how an EJB client/server system operates and the underlying
architecture of EJB, we need to understand the basic parts of an EJB system: the EJB
component, the EJB container, and the EJB object.
architecture of EJB, we need to understand the basic parts of an EJB system: the EJB
component, the EJB container, and the EJB object.
The Enterprise JavaBeans Component
An Enterprise JavaBean is a component, just like a traditional JavaBean. Enterprise
JavaBeans execute within an EJB container, which in turn executes within an EJB server.
Any server that can host an EJB container and provide it with the necessary services can
be an EJB server. (Hence, many existing servers are being extended to be EJB servers.)
An EJB component is the type of EJB class most likely to be considered an “Enterprise
JavaBean”. It’s a Java class, written by an EJB developer, that implements business logic.
All the other classes in the EJB system either support client access to or provide services
(like persistence, and so on) to EJB component classes.
JavaBeans execute within an EJB container, which in turn executes within an EJB server.
Any server that can host an EJB container and provide it with the necessary services can
be an EJB server. (Hence, many existing servers are being extended to be EJB servers.)
An EJB component is the type of EJB class most likely to be considered an “Enterprise
JavaBean”. It’s a Java class, written by an EJB developer, that implements business logic.
All the other classes in the EJB system either support client access to or provide services
(like persistence, and so on) to EJB component classes.
The Enterprise JavaBeans Container
The EJB container is where the EJB component “lives”. The EJB container provides
services such as transaction and resource management, versioning, scalability, mobility
services such as transaction and resource management, versioning, scalability, mobility
persistence, and security to the EJB components it contains. Since the EJB container
handles all these functions, the EJB component developer can concentrate on business
rules, and leave database manipulation and other such fine details to the container. For
example, if a single EJB component decides that the current transaction should be
aborted, it simply tells its container (container is responsible for performing all rollbacks,
or doing whatever is necessary to cancel a transaction in progress). Multiple EJB
component instances typically exist inside a single EJB container.
handles all these functions, the EJB component developer can concentrate on business
rules, and leave database manipulation and other such fine details to the container. For
example, if a single EJB component decides that the current transaction should be
aborted, it simply tells its container (container is responsible for performing all rollbacks,
or doing whatever is necessary to cancel a transaction in progress). Multiple EJB
component instances typically exist inside a single EJB container.
The EJB Object and the Remote Interface
Client programs execute methods on remote EJBs by way of an EJB object. The EJB
object implements the “remote interface” of the EJB component on the server. The remote
interface represents the “business” methods of the EJB component. The remote interface
does the actual, useful work of an EJB object, such as creating an order form or deferring
a patient to a specialist. EJB objects and EJB components are separate classes, though
from the outside (i.e., by looking at their interfaces), they look identical. This is because,
they both implement the same interface (the EJB component’s remote interface), but they
do very different things. An EJB component runs on the server in an EJB container and
implements the business logic. The EJB object runs on the client and remotely executes
the EJB component’s methods.
object implements the “remote interface” of the EJB component on the server. The remote
interface represents the “business” methods of the EJB component. The remote interface
does the actual, useful work of an EJB object, such as creating an order form or deferring
a patient to a specialist. EJB objects and EJB components are separate classes, though
from the outside (i.e., by looking at their interfaces), they look identical. This is because,
they both implement the same interface (the EJB component’s remote interface), but they
do very different things. An EJB component runs on the server in an EJB container and
implements the business logic. The EJB object runs on the client and remotely executes
the EJB component’s methods.
Let us consider an analogy to understand the concept of EJB. Assume your VCD player is
an EJB component. The EJB object is then analogous to your remote control: both the
VCD and the remote control have the same buttons on the front, but they perform
different functions. By pushing the Rewind button on your VCD player’s remote control
is equivalent to pushing the Rewind button on the VCD player itself, even though it's the
VCD player -- and not the remote -- that actually rewinds a tape.
Working of EJB
The actual implementation of an EJB object is created by a code generation tool that
comes with the EJB container. The EJB object's interface is the EJB component's remote
interface. The EJB object (created by the container and tools associated with the
container) and the EJB component (created by the EJB developer) implement the same
remote interface. To the client, an EJB object looks just like an object from the
application domain -- an order form, for example. But the EJB object is just a stand-in for
the actual EJB, running on the server inside an EJB container. When the client calls a
method on an EJB object, the EJB object method communicates with the remote EJB
container, requesting that the same method be called, on the appropriate (remote) EJB,
with the same arguments, on the client's behalf. This is explained with the help of the
Figure1. This is the core concept behind how an EJB client/server system works.
No comments:
Post a Comment