Java Reference
In-Depth Information
The tool
rmic
can be used in a number of ways depending on context.
rmic
allows for
compatibility with previous versions of Java such as Java 1.1 (stubs and skeletons) and Java 1.2
(stubs only). J2SE 1.5 does not require the use of skeletons, but as we mentioned earlier, you
must still use
rmic
with your project submission.
■
Note
The skeleton interface has been deprecated in the Java 2 platform (i.e., JDK version 1.2 and
greater). To create stubs for version 1.2 only in our RMI implementation, we use the following syntax
with
rmic
:
rmic -v1.2 sampleproject.remote.DVDDatabaseImpl
■
Note
RMI makes use of the Proxy design pattern. The Proxy pattern designates a surrogate object that
controls access to the real object. There are three key players in this design pattern: a
Subject
,a
Proxy
,
and a
Real-Subject
. The Proxy object has a reference to the
Real-Subject
and is responsible for com-
munication to and from the
Real-Subject
. The
Subject
displays the same interface for both the
Proxy
and the
Real-Subject
. The
Real-Subject
is the actual implementation of the object the
Proxy
repre-
sents and that the
Subject
has defined. In RMI, the
Subject
corresponds to the remote implementation.
The stub is the
Proxy
and the remote object implementation is the
Real-Subject
. Figure 6-13 illustrates
the various elements in the Proxy design pattern.
Figure 6-13.
The Proxy design pattern
For backward stub//skeleton compatibility with previous versions of Java, you can read more about
rmic
at
http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/rmic.html
for Windows. For
Unix, visit
http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/rmic.html
.
Parameter Passing
RMI method invocations require communication between objects on different machines and
in different JVMs, even though the call behaves as if it is a local call within the same JVM.
This section describes how RMI transfers parameters and return values between different