Java Reference
In-Depth Information
Chapter 5
Remote Method Invocation (RMI)
Learning Objectives
After reading this chapter, you should:
￿ understand the fundamental purpose of RMI;
￿ understand how RMI works;
￿ be able to implement an RMI client/server application involving .class fi les that
are available locally;
appreciate the potential danger presented by .class fi les downloaded from remote
know how security managers may be used to overcome the above danger.
With all our method calls so far, the objects upon which such methods have been invoked
have been local . However, in a distributed environment, it is often desirable to be able to
invoke methods on remote objects (i.e., on objects located on other systems). RMI
( Remote Method Invocation ) provides a platform-independent means of doing just this.
Under RMI, the networking details required by explicit programming of streams and
sockets disappear and the fact that an object is located remotely is almost transparent to
the Java programmer. Once a reference to the remote object has been obtained, the
methods of that object may be invoked in exactly the same way as those of local objects.
Behind the scenes, of course, RMI will be making use of byte streams to transfer data and
method invocations, but all of this is handled automatically by the RMI infrastructure.
RMI has been a core component of Java from the earliest release of the language, but has
undergone some evolutionary changes since its original specifi cation.
The Basic RMI Process
Though the above paragraph referred to obtaining a reference to a remote object,
this was really a simplifi cation of what actually happens. The server program that
has control of the remote object registers an interface with a naming service, thereby
making this interface accessible by client programs. The interface contains the
Search WWH ::

Custom Search