This book discourages implementing the remote interface in the bean class, even though this makes it a little more difficult to enforce consistency between the business methods defined in the remote interface and the corresponding methods on the bean class. There are good reasons for not implementing the remote interface in the bean class, but there is also a need for a common interface to ensure that the bean class and remote interface define the same business methods. This section describes a design alternative that allows you to use a common interface to ensure consistency between the bean class and the remote interface.
There should be no difference, other than
java.rmi.RemoteException, between the
business methods defined in the
ShipBean class and
their corresponding business methods defined in the
ShipRemote interface. EJB requires you to match
the method signatures so that the remote interface can accurately
represent the bean class on the client. Why not implement the remote
com.titan.ShipRemote in the
ShipBean class to ensure that these methods are
EJB allows a bean class to implement its remote interface, but this
practice is discouraged for a couple of reasons. First, the remote
interface is actually an extension of the
javax.ejb.EJBObject interface, which you learned
about in Chapter 5. This interface defines several methods that are ...