Java Reference
In-Depth Information
Figure 18.1 This diagram
shows the stub/skeleton
mechanism that RMI uses
to allow methods in the
client and remote objects
on different platforms to
invoke methods in the
other object across the
network.
object? The simple requirements are summarized here:
The remote class must be split into both an interface and an implementation class.
Each remotely callable method must be declared in the interface.
The interface must extend java.rmi.remote .
The declaration of each remotely callable method in the interface must include
java.rmi.RemoteException in the throws clause.
If another remote object is included in the parameter list or the return value, it must be
declared using the corresponding remote interface rather than the implementation class.
The implementation class must extend java.rmi.server.RemoteObject or,
normally, the subclass j ava.rmi.server.UnicastRemoteObject .
That list may sound daunting, but using it is really quite simple. Each of these
requirements is explained in more detail in the following sections.
18.3.3.1 The remote interface
Any class that wishes to be remotely accessible must first be split into a Java
interface that declares the remotely callable methods and an implementation
class that provides the implementation of those methods. Said another way, each
remotely callable method must be defined in an interface that the remote class
implements.
The interface declares the methods that are to be remotely accessible and
is referred to as a remote interface .Tobearemote interface, the interface
class must extend, either directly or indirectly, the java.rmi.Remote inter-
face. Also, each method declared in the remote interface must include the
java.rmi.RemoteException (or one of its superclasses) in its throws
clause.
All method parameters and return values that are either primitives or regular
objects - either standard Java language objects or custom objects the developer
defines - are treated just as in a normal non-remote method. However, there is
Search WWH ::




Custom Search