JSP Tag Libraries

Скачать в pdf «JSP Tag Libraries»


Listing 12.1 The remote interface of the CatalogueEntry EJB


package book.ejb.catalogue;


import javax.ejb.EJBObject; import java.rmi.RemoteException;


public interface CatalogueEntry


extends EJBObject {


public String getName() e throws RemoteException;


public void setName(String name) e throws RemoteException;


public String getSerial() e throws RemoteException;


public String getDescription() e throws RemoteException;


public void setDescription(String description) e throws RemoteException;


public String getType() e throws RemoteException;


public void setType(String type) e throws RemoteException;


public int getPriceCents() e throws RemoteException;


public void setPriceCents(int cents) e throws RemoteException;


public int getPriceDollars() e throws RemoteException;


}



public void setPriceDollars(int dolars) throws RemoteException;



e


О Declaration of the CatalogueEntry interface Two things are obvious about this remote interface (both required by the EJB specification):


1    The remote interface does not extend the interface java.rmi.Remote in the same way that the usual RMI remote interfaces do; instead, it extends javax.ejb.EJBObject. The methods in javax.ejb.EJBObject (that are implemented by the container) let their caller perform operations such as removing the EJB from the container


2    All the methods in the interface throw a RemoteException because EJBs are subject to distribution and, in most cases, a method call on an EJB is actually a remote method call. In these cases we need the RemoteException to signal us that some error has occurred.


Other than these two findings, the methods seem obvious. We have methods to set and get most of the catalogue entry’s properties, with the sole exception being that the serial number has only a getter, since it is the key to the catalogue entry and cannot be changed.

Скачать в pdf «JSP Tag Libraries»