Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Enterprise JavaBeans™ Specification, Version 2.0 - Sun Microsystems.pdf
Скачиваний:
14
Добавлен:
24.05.2014
Размер:
2.71 Mб
Скачать

Sun Microsystems Inc.

Client View of an Entity

Enterprise JavaBeans 2.0, Public Draft

EJB Container

From its creation until its destruction, an entity object lives in a container. Transparently to the client, the container provides security, concurrency, transactions, persistence, and other services for the entity objects that live in the container. The container is transparent to the client—there is no API that a client can use to manipulate the container.

Multiple clients can access an entity object concurrently. The container in which the entity bean is deployed properly synchronizes access to the entity object’s state using transactions.

Each entity object has an identity which, in general, survives a crash and restart of the container in which the entity object has been created. The object identity is implemented by the container with the cooperation of the enterprise bean class.

The client view of an entity bean is location independent. A client running in the same JVM as an entity bean instance uses the same API to access the entity bean as a client running in a different JVM on the same or different machine.

A client of an entity object can be another enterprise bean deployed in the same or different Container; or a client can be an arbitrary Java program, such as an application, applet, or servlet. The client view of an entity bean can also be mapped to non-Java client environments, such as CORBA clients not written in the Java programming language.

Multiple enterprise beans can be deployed in a container. For each entity bean deployed in a container, the container provides a class that implements the entity bean’s home interface. The home interface allows the client to create, find, and remove entity objects within the enterprise bean’s home as well as execute home business methods which are not specific to a particular entity bean object. A client can look up the entity bean’s home interface through JNDI; it is the responsibility of the container to make the entity bean’s home interface available in the JNDI name space.

A client view of an entity bean is the same, irrespective of the implementation of the entity bean and its container. This ensures that a client application is portable across all container implementations in which the entity bean might be deployed.

8.2 EJB Container

An EJB Container (Container for short) is a system that functions as a runtime container for enterprise beans.

Multiple enterprise beans can be deployed in a single container. For each entity bean deployed in a container, the container provides a home interface that allows the client to create, find, and remove entity objects that belong to the entity bean. The home interface may also provide home business methods, which are not specific to a particular entity bean object. The container makes the entity beans’ home interfaces (defined by the bean provider and implemented by the container provider) available in the JNDI name space for clients.

An EJB Server may host one or multiple EJB Containers. The containers are transparent to the client: there is no client API to manipulate the container, and there is no way for a client to tell in which container an enterprise bean is installed.

5/31/00

94

Sun Microsystems Inc

EJB Container

Enterprise JavaBeans 2.0, Public Draft

Client View of an Entity

8.2.1 Locating an entity bean’s home interface

A client locates an entity bean’s home interface using JNDI. For example, the home interface for the Account entity bean can be located using the following code segment:

Context initialContext = new InitialContext(); AccountHome accountHome = (AccountHome)

javax.rmi.PortableRemoteObject.narrow(

initialContext.lookup(“java:comp/env/ejb/accounts”),

AccountHome.class);

A client’s JNDI name space may be configured to include the home interfaces of enterprise beans deployed in multiple EJB Containers located on multiple machines on a network. The actual location of an EJB Container is, in general, transparent to the client.

8.2.2 What a container provides

The following diagram illustrates the view that a container provides to the clients of the entity beans deployed in the container.

95

5/31/00