Distributed Java Applications with RMI

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 remote 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. Define a remote interface. A remote interface always extends the java.rmi.Remote interface and must throw a java.rmi.RemoteException.

  2. Implement the remote interface. By extending the java.rmi.UnicastRemoteObject class, you create the server class that implements your remote interface.

  3. Compile the server class. This is done using any Java compiler.

  4. Run the stub compiler, rmic. The rmic compiler creates client and server stubs for your remote class from your server's .class file.

  5. 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.

  6. Start your server objects. You must load your server classes and then create instances of remote objects.

  7. Register your remote objects with the registry. Each instance of a server object must be registered using the java.rmi.Naming class.

For the Client:

  1. Write the client code. The java.rmi.Naming class is used to locate a remote server object. Methods are invoked on this remote object using the client stubs created by rmic.

  2. Compile the client code with any Java compiler.

  3. Start the client.

In the future, there will be greater convergence between RMI and CORBA. RMI enhancements included in the JDK 1.2 release include support for persistent object references and support for remote object activation. Sun also has announced plans to provide a version of RMI that works over the IIOP transport. This will provide RMI with built-in support for propagation of transactions, ORB-based firewall support (as opposed to the current HTTP tunneling), and interoperability with objects written in other languages via the RMI/IDL subset.



Software Development. Building Reliable Systems
Software Development: Building Reliable Systems
ISBN: 0130812463
EAN: 2147483647
Year: 1998
Pages: 193
Authors: Marc Hamilton

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net