RMI
(Remote Method Invocation)
Terminology
• A remote object is an object on another computer
• The client object is the object making the request (sending a
message to the other object)
• The server object is the object receiving the request
• As usual, “client” and “server” can easily trade roles (each can
make requests of the other)
• The rmiregistry is a special server that looks up objects by
name
– Hopefully, the name is unique!
• rmic is a special compiler for creating stub (client) and skeleton
(server) classes
Processes
• For RMI, you need to be running three processes
– The Client
– The Server
– The Object Registry, rmiregistry, which is like a DNS
service for objects
• You also need TCP/IP active
Interfaces
• Interfaces define behavior
• Classes define implementation
• Therefore,
– In order to use a remote object, the client must know its
behavior (interface), but does not need to know its
implementation (class)
– In order to provide an object, the server must know both its
interface (behavior) and its class (implementation)
• In short,
– The interface must be available to both client and server
– The class should only be on the server
Classes
• A Remote class is one whose instances can be
accessed remotely
– On the computer where it is defined, instances of this class can be
accessed just like any other object
– On other computers, the remote object can be accessed via object
handles
• A Serializable class is one whose instances can be
marshaled (turned into a linear sequence of bits)
– Serializable objects can be transmitted from one computer to another
• It probably isn’t a good idea for an object to be both
remote and serializable