The Remote Home Interface
Entity beans’ home interfaces (local and remote) are used to
create, locate, and remove objects from EJB systems. Each entity bean
has its own remote or local home interface. The home
interface defines two basic kinds of methods: zero or more create
methods, and one or more find methods.[37] In this
example, the create methods act like remote constructors and define
how new Ship EJBs are created. (In our home interface, we provide
only a single create method.) The find method is used to locate a
specific Ship or Ships.The following code contains the complete
definition of the ShipHomeRemote
interface:
package com.titan.ship; import javax.ejb.EJBHome; import javax.ejb.CreateException; import javax.ejb.FinderException; import java.rmi.RemoteException; import java.util.Collection; public interface ShipHomeRemote extends javax.ejb.EJBHome { public ShipRemote create(Integer id, String name, int capacity, double tonnage) throws RemoteException,CreateException; public ShipRemote create(Integer id, String name) throws RemoteException,CreateException; public ShipRemote findByPrimaryKey(Integer primaryKey) throws FinderException, RemoteException; public Collection findByCapacity(int capacity) throws FinderException, RemoteException; }
Enterprise JavaBeans specifies that create methods in the home
interface must throw the
javax.ejb.CreateException
. This provides the EJB container with a common exception for communicating problems experienced during the create process. ...
Get Enterprise JavaBeans, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.