Java Reference
In-Depth Information
Chapter 18
Java Remote Method Invocation (RMI)
18.1 Introduction
Chapters 16 and 17 described the client/server or distributed object paradigm
at a somewhat abstract level using the UML notation language. Because of the
abstract nature of that discussion there was almost no Java code in either of those
chapters. In fact, the only place that any code snippets appeared at all was to
illustrate UML concepts in a familiar concrete Java environment.
Now we will begin to explain how to really implement the distributed object
paradigm using Java Remote Method Invocation (RMI). By the end of this chapter,
we will have some real code that demonstrates simple communication between
two distributed Java objects, though we still won't have a running application
using the architecture of Chapters 16 and 17. That complete application will be
developed in Chapter 20.
Before getting to the real code, we must first describe how distributed com-
puting can be implemented. The concepts are not particularly new, nor are
they unique to Java. However, just as in other areas, the Java platform offers
advantages and an easy programming style that are absent in other languages.
These advantages are discussed as we explain how distributed computing works.
While the full capabilities of RMI are beyond the scope of this topic, we will
learn the basics of RMI, and with these skills we can implement the distributed
architecture described in Chapters 16 and 17.
18.2 How distributed computing works
Consider a conventional (non-distributed) computer program, be it written in Java
or some other language. Certain program elements, call them “functions” as in
C, or “subroutines” as in Fortran, or “methods” as in C
and Java, will call
other program elements. All these program elements (we call them functions
for simplicity) are typically loaded somewhere into the machine memory
allocated for the program, and each function has a unique memory address.
A computer's program counter points to the address of the next machine-level
instruction to be executed. Through the magic of compilation and linking, a
++
501
Search WWH ::




Custom Search