Java Reference
In-Depth Information
these advantages, it is clear that Java and RMI provide an excellent platform for
distributed computing while retaining the object oriented nature of Java.
An alternative to RMI is the Common Object Request Broker Architecture
(CORBA). CORBA has some advantages over RMI, particularly because it is
language independent, meaning that C or C
++
clients, for example, can make
CORBA calls on a Java server or vice versa. While Java RMI requires Java on
both the client and the server, CORBA permits the use of any programming
language that has a CORBA binding. The most popular languages that support
CORBA are C
and Java. Yes, Java fully supports CORBA as well as RMI,
and the CORBA support is built into Java, just like the RMI support. Because
of the added complexities required to be language independent, CORBA is more
difficult to use than RMI, is not as fully object oriented as Java, and suffers
some performance penalties compared to RMI. However, CORBA remains an
important technology that has a well-deserved place in the distributed computing
world. We discuss CORBA in more detail in Chapter 19.
++
18.3 RMI overview
RMI is the mechanism that allows an object in one Java virtual machine to invoke
methods on an object running in another Java virtual machine. Both JVMs may
be present on the same physical computer or, as is more likely, the JVMs can be
on different computers connected over a network. While RMI works for applets
too, we consider two Java applications, rather than applets, running in the two
JVMs. One of the Java applications can be thought of as the client and one as the
server. Neither Java application is a standalone entity. It is the sum of the client
and server applications together that offers a useful whole program to the user.
18.3.1 Remote objects and remote exceptions
An RMI server application typically creates several server-side objects, makes
them remotely accessible (i.e. accessible by other JVMs), and then waits for
external clients to invoke methods on them. These remotely accessible server-
side objects are referred to as remote objects. Server-side objects may also include
methods that are not made remotely accessible. Such methods are available only
locally within the server application. We explain below the simple steps necessary
to create remote objects.
Ignoring the degenerate case of running both JVMs on the same host, a network
is assumed to be present between the client and server. Because the possible failure
modes increase when additional machines and networks are in the mix, RMI
client applications must be prepared to deal with additional exceptions. These
extra exceptions are grouped under the java.rmi.RemoteException class.
One of the design goals for RMI was that it should fit naturally into the Java
programming language. As such, the semantics for making a remote call are
Search WWH ::




Custom Search