Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL

Chapter 21. Distributed Applications wit... > Distributed Java Applications with R... - Pg. 184

Distributed Applications with CORBA, RMI, and DCOM 184 Distributed Java Applications with RMI Version 1.1 of the Java Development Kit (JDK) introduced the Remote Method Invocation (RMI) API to support remote method invocations on objects across Java virtual machines. RMI provides new Java interfaces to find remote objects, load them, and then run them securely. One can think of RMI as a mini-CORBA for Java. RMI was never intended to compete against CORBA, as DCOM does, but rather to offer a subset of CORBA functionality for pure Java environments. Because it offers a small subset of the CORBA functionality, RMI can be much easier to learn than CORBA for new developers. RMI fills a definite need, as many applications have a simple requirement for re- mote method invocation without all the functionality of CORBA. On the other hand, larger, more complicated distributed systems developers might just do very well to take the plunge and use CORBA. To help compare CORBA and RMI, let's examine the steps you would follow to create an RMI client and server. For the Server: 1. 2. 3. 4. 5. Define a remote interface. A remote interface always extends the java.rmi.Remote interface and must throw a java.rmi.RemoteException. Implement the remote interface. By extending the java.rmi.UnicastRemoteObject class, you create the server class that implements your remote interface. Compile the server class. This is done using any Java compiler. Run the stub compiler, rmic. The rmic compiler creates client and server stubs for your remote class from your server's .class file. Start the RMI registry on your server. The RMI registry implements a non-persistent naming service for RMI servers. Only one RMI registry per server machine is required.