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

Sun Microsystems Inc

Home interface

Enterprise JavaBeans 2.0, Public Draft

Client View of a Session Bean

A client can pass a home interface object reference to another application. The receiving application can use the home interface in the same way that it would use a home interface object reference obtained via JNDI.

5.2.2 What a container provides

The following diagram illustrates the view that a container provides to clients of session beans.

Figure 2

Client View of session beans deployed in a Container

container

 

EJB objects

 

EJB objects

 

EJBObjects

 

EJBHome

client

session bean 1

 

EJB objects

EJB objects

EJBObjects

EJBHome

session bean 2

5.3 Home interface

A Container implements the home interface of the enterprise bean installed in the container. The object that implements a session bean’s home interface is called a session EJBHome object. The container makes the session beans’ home interfaces available to the client through JNDI.

The home interface allows a client to do the following:

Create a new session object.

49

5/31/00

Sun Microsystems Inc.

Client View of a Session Bean

Enterprise JavaBeans 2.0, Public Draft

Home interface

Remove a session object.

Get the javax.ejb.EJBMetaData interface for the session bean. The javax.ejb.EJBMetaData interface is intended to allow application assembly tools to discover information about the session bean, and to allow loose client/server binding and cli- ent-side scripting.

Obtain a handle for the home interface. The home handle can be serialized and written to stable storage. Later, possibly in a different JVM, the handle can be deserialized from stable storage and used to obtain back a reference of the home interface.

5.3.1 Creating a session object

A home interface defines one or more create<METHOD>(...) methods, one for each way to create a session object. The arguments of the create methods are typically used to initialize the state of the created session object.

The following example illustrates a home interface that defines two create<METHOD>(...) methods:

public interface CartHome extends javax.ejb.EJBHome { Cart create(String customerName, String account) throws RemoteException, BadAccountException,

CreateException;

Cart createLargeCart(String customerName, String account) throws RemoteException, BadAccountException,

CreateException;

}

The following example illustrates how a client creates a new session object using a create<METHOD>(...) method of the CartHome interface:

cartHome.create(“John”, “7506”);

5.3.2 Removing a session object

A client may remove a session object using the remove() method on the javax.ejb.EJBObject interface, or the remove(Handle handle) method of the javax.ejb.EJBHome interface.

Because session objects do not have primary keys that are accessible to clients, invoking the javax.ejb.EJBHome.remove(Object primaryKey) method on a session results in the javax.ejb.RemoveException.

5/31/00

50