Defining a Remote Interface
Remote method invocations can fail in very different ways from
local method
invocations, due to network related communication problems and server
problems. To indicate that it is a remote object, an object implements a
remote
interface, which has the following characteristics:
- The remote interface must be public. Otherwise, a client will get
an error
when attempting to load a remote object that implements the remote
interface.
- The remote interface extends the interface
java.rmi.Remote
.
- Each method must declare
java.rmi.RemoteException
in its
throws
clause, in addition to any application-specific exceptions.
- A remote object passed as an argument or return value (either directly
or
embedded within a local object) must be declared as the remote interface,
not the implementation class.
Next is the interface definition for a thermometer.