EJB.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 API.

The home interface allows a client to do the following:

  • Create a new session object.

  • 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 client-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.

EJB.5.3.1 Creating a Session Object

A home interface defines one or more create(...) 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 a single create(...) method:

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

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

 cartHome.create("John", "7506"); 

EJB.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 r emove(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.Home.remove(Object primaryKey) method on a session results in the javax.ejb.RemoveException .



Java 2 Platform, Enterprise Edition. Platform and Component Specifications
Java 2 Platform, Enterprise Edition: Platform and Component Specifications
ISBN: 0201704560
EAN: 2147483647
Year: 2000
Pages: 399

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net