Entity bean Remote component interface
package headfirst; import javax.ejb.*; import java.rmi.RemoteException; public interface Customer extends EJBObject { public String getLastName() throws RemoteException; public void setLastName(String lastName) throws RemoteException; public String getFirstName() throws RemoteException; public void setFirstName(String firstName) throws RemoteException; }
Rules for the Remote component interface
Import javax.ejb.* and java.rmi.RemoteException
Extend javax.ejb.EJBObject
Declare one or more business methods, that throw a RemoteException
Arguments and return types must be RMI-IIOP compatible (Serializable, primitive, Remote, or arrays or collections of any of those)
You can have overloaded methods
Each method must declare a RemoteException
You can declare your own application exceptions, but they must NOT be runtime exceptions (in other words, they must be compiler-checked exceptions—subclasses of Exception but not subclasses of RuntimeException)
Methods can have arbitrary names, as long as they don’t begin with “ejb”.
Get Head First EJB 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.