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

Sun Microsystems Inc.

Client View of a Session Bean

Enterprise JavaBeans 2.0, Public Draft

EJB Container

Each session object has an identity which, in general, does not survive a crash and restart of the container, although a high-end container implementation can mask container and server crashes to the client.

The client view of a session bean is location-independent. A client running in the same JVM as the session object uses the same API as a client running in a different JVM on the same or different machine.

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

Multiple enterprise beans can be installed in a container. The container allows the clients to look up the home interfaces of the installed enterprise beans via JNDI. A session bean’s home interface provides methods to create and remove the session objects of a particular session bean.

The client view of an session object is the same, irrespective of the implementation of the session bean and the container.

5.2 EJB Container

An EJB Container (container for short) is a system that functions as the “container” for enterprise beans. Multiple enterprise beans can be deployed in the same container. The container is responsible for making the home interfaces of its deployed enterprise beans available to the client through JNDI. Thus, the client can look up the home interface for a specific enterprise bean using JNDI.

5.2.1 Locating a session bean’s home interface

A client locates a session bean’s home interface using JNDI. For example, the home interface for the Cart session bean can be located using the following code segment:

Context initialContext = new InitialContext();

CartHome cartHome = (CartHome)javax.rmi.PortableRemoteObject.narrow( initialContext.lookup(“java:comp/env/ejb/cart”), CartHome.class);

A client’s JNDI name space may be configured to include the home interfaces of enterprise beans installed in multiple EJB Containers located on multiple machines on a network. The actual locations of an enterprise bean and EJB Container are, in general, transparent to the client using the enterprise bean.

The lifecycle of the distributed object implementing the home interface (the EJBHome object) is Con- tainer-specific. A client application should be able to obtain a home interface, and then use it multiple times, during the client application’s lifetime.

5/31/00

48