2. RMI versus Remote Process Calls (RPC)
2.1 Remote Method Invocation (RMI)
RMI was developed by Sun to provide remote communication
solely between Java objects. The idea behind this is that a Java
dedicated mechanism would be able to take advantage of all of
Java's key object and security features otherwise ignored by more
general communication mechanisms.
Thus RMI is a mechanism that allows client java objects to connect
to remote java objects and use them as if they were local to that
client. A look at the RMI architecture reveals how this is achieved.
Firstly, the RMI architecture separates the code that defines
the behaviour from that which implements the behaviour enabling
them to run on separate Java Virtual Machine's (JVM). It should
be noted that a Java interface contains no executable code. Instead
RMI supports two classes that implement the same interface. The
first class, run on the server, is the implementation of the behaviour
and the second class, run on the client acts as a proxy for the
remote service. Figure 1 illustrates this structure.
Figure 1.
RMI implementation structure [2]
To allow the client and server objects
to forward method calls between one another RMI employs a proxy
pattern, known as a Stub and Skeleton. Figure 2 illustrates the
stub and skeleton role.

Figure 2.
Role of the Stub and Skeleton in RMI [2]
When a method is 'called on the remote
object' the call is actually made on the local proxy object or
stub object. The stub communicates with a skeleton object in same
space as the remote object being accessed. This communication
is performed transparent to the client and it is the function
of the stub-skeleton pair to hide the transport and session layers,
in particular note the conversion of method parameters (including
objects) to and from byte streams.
All the required classes for RMI implementation
are included in the JDK development kit (java.rmi.*).
Next Page