Home Interface
- factory methods for locating, creating and removing instances of EJB beans
- defined by EJB developer for each bean type
- inherits from javax.ejb.EJBHome:
public interface javax.ejb.EJBHome extends Remote {
public abstract void remove (Handle handle)
throws RemoteException, RemoveException;
public abstract void remove (Object primaryKey)
throws RemoteException,RemoveException;
public abstract EJBMetaData getEJBMetaData ()
throws RemoteException;
}
public interface EJBMetaData {
EJBHome getEJBHome();
Class getHomeInterfaceClass();
Class getRemoteInterfaceClass();
Class getPrimaryKeyClass();
boolean isSession();
boolean isStatelessSession();
}
- the interface should provide one or more create() methods, one for each way
the new bean instance may be created.
Example
public interface AccountHome extends javax.ejb.EJBHome {
Account create(String clientName)
throws javax.ejb.CreateException,
java.rmi.RemoteException;}
- The container tools will automatically generate the factory implementation.
- EJB Bean class must implement an ejbCreate(...) method for each create(...) method defined
in the home interface. For stateless session beans, only one create() method with
no parameters is allowed.
- to allow clients locate existing entity beans, the home interface may also provide "finder"
methods to search for an entity bean based on specified searching criteria. For bean-managed
persistance, the critera to select the appropriate bean is specified in the deployment descriptor
(in the form of the WHERE clause of the SELECT SQL command).
The Home interface (or the object generated by the container's deployment tools
which implements it) have to be registered with the container so that clients can create new beans. The name
under which the home interface is registered with the naming service is specified
in deployment descriptor.
Note: The Home object is the implementation of the Home interface,
automatically generated by container provider's deployment tool.
|