Distributed Objects   «Prev  Next»

Lesson 3What are EJB clients, servers, containers, and beans?
ObjectiveDescribe relationship between EJB clients, servers, containers, and beans themselves.

What are EJB Clients, Servers, and Containers?

Architecture


Consider the following diagram:
Persistence, Naming, Security, Transaction Management, Lifecycle, State Management, Factory, Concurrency
Persistence, Naming, Security, Transaction Management, Lifecycle, State Management, Factory, Concurrency

EJBs are managed components. The runtime environment (the server[1], the container[2], and the bean) is an instance of an Object Monitor as described in the previous module.
The bean contains the business logic and the container/server provides the plumbing.
To be a bean, the bean has to obey certain rules that form a contract between it and the container.
The server has a much smaller role to play than the container and will be omitted from many of the diagrams that follow.
The client never actually communicates directly with the bean object.
All messages sent to the bean are intercepted by the container before being passed onto the bean, allowing transaction management, security, etc. to be applied by the container.

Contracts

The diagram below shows the two major contracts in the EJB object:
  1. the contract between a client and the container, and
  2. the contract between the bean and its container.
These contracts describe the "rules of engagement" between the different entities.
These rules are very precise and allow a uniform development model and portable beans and clients.

1. Contract between a client and container 2. Contract between the bean and its container
1. Contract between a client and container 2. Contract between the bean and its container

The diagram illustrates a remote client running outside of the container.
The client view would be the same if the client were another bean running deployed inside the same container, and the semantics would be the same for each. We will cover the details of these contracts as we go through the code in later modules.

How are they built?

What form do these entities have in the physical universe of the computer? This varies from one vendor to another. The bean, the container, and the server are logical entities, not physical. The simplest method is to combine the server, the container, the bean's skeleton, and the bean into one program and load and execute it.
In the next lesson, services provided by the container will be discussed.

[1]Server: That part of a object monitor that handles networking and distributed services.
[2]Container: That part of a object monitor that manages the remote object and provides system services.