![]() |
|
||||||||||||||||
|
|||||||||||||||||
RMI: Java's Library Paste Updated Dec 10, 2000
| Overview Tutorials Examples Serialization Applets, Servlets RMI-IIOP Advanced Vendor Specific Book References |
|
See also: Java Skyline: Enterprise Java Skyline: Learn JNDI jGuru RMI FAQ managed by Govind Seshadri Java Spaces Java RMI FAQ |
||||||
| If Java is a "glue" language, Remote Method Invocation (RMI) is its original "library paste" Now the communications protocol for EJB. RMI is built into Java and is an integral part of the language. | ||||||||
|
|
||||||||
| RMI provides Java with a powerful capability to build multi-server and multi-platform
applcications. See Design networked applications in RMI using the Adapter design pattern by Dan Becker, JavaWorld May 1999. The SunWorld article, Exploit distributed Java computing
with RMI by Piroz Mohseni compares RMI and RPC. Robert Reeves presents a series of slide show presentations on RMI for his Networks and Distributed Computing course at Queensland University. On Digital Cats, Qusay H. Mahmoud presents an architectural overview of the OSI Reference model and shows how RMI works within it in Distributed Objects Programming Using Java RMI. The NCWorld article, Exploit distributed Java computing with RMI Part 1 by Piroz Mohseni, Jan 1998 compares RMI and RPC. In part 2, Piroz explains argument passing and the concept of argument marshalling. On Webacopia, Gopalan Suresh Raj explains what RMI does in RMI under the Hood. |
||||||||
| I wish there were more of these that told the whole story. Recommended: Sree
Pradhip has a good one on the UNCCharlote JUG Site that goes through all the creation and setup steps called Hello World using RMI. Another similarly good tutorial appears in the Client/Server
Programming with Java and CORBA
book listed below under Books. Third Eye Consulting has a simple Introduction to RMI tutorial, by Chris Bonham. Also, take a look at the "jGuru" short course Fundamentals of RMI, Feb 2000,available on the JDC. Another interesting starter if you are coming from an applet background is Introduction to Remote Method Invocation by Sameer Tyagi (Java Boutique). And if you have a servlet- JDBC background, see Sree Pradhip's Login Use Case using JDBC-RMI Servlets. Because an RMI application runs in multiple JVMs, it can present special challenges for debugging. See Java Tip 56: How to eliminate debugging problems for RMI-based applications by Satheesh A. Donthy JavaWorld, for help. Nancy McCracken at NPAC Syracuse University provides this Overview of Distributed Objects and RMI, Feb 1998. The code for a simple hello example can be found here: client and here: server. |
||||||||
| Simple: The CountRMI example
from Client/Server Programming with Java and CORBA is available
here. There is also a slightly modified example with Windows
NT instructions from Niels Olof Bouvin, University of Texas. Getting started using RMI in the Sun JDK 1.2 RMI API docs shows you how to build the "Hello World" example. Prof. M. Abrams of Virginia Tech gives a classroom presentation for this example. The JDK 1.2 docs also provide a socket factory example in Creating a Custom RMI Socket Factory. Practical: Roger Whitney of San Diego State offers this interesting RMI Stock Watch example.as part of his Java Distributed Computing course, Spring 1999. TECFA provides this example you can download. On Webacopia, Gopalan Suresh Raj shows how to make this nice Stock Market quote example run. Jonathan Knudsen also presents a nice example in Battle Droids and RMI, Jun 1999, Byte-size Java, O'Reilly. For an extensive example that uses Swing and includes dynamic class loading see: Revolutionary RMI by Andy Krumel, JavaWorld Dec 1998. Although RMI is a client/server architecture, it also enables the client and server to interact as peers. See the example in How Do I Implement Callbacks with Java's RMI by Govind SeshadriDr. Dobb's Journal, Mar 1998. For a good explanation of Call Backs see RMI Callbacks in JavaWorld Q&A, May 1999. |
||||||||
| But there's even more to RMI - it also incorporates a transport mechanism
for objects called object serialization. Serialization allows send objects by flattening them into an output stream, and then reconstruct
them at the other end. Serialization is very easy. To make a serializable object you just declare that it implements
Serializable. Serialization
is then automatic and thus makes RMI - and other object transport mechanisms quite easy to implement. Despite the close association between RMI and serialization, you also can use RMI without serialization. You can instead declare an object implements Externalizable and then write the readExternal() and writeExternal() methods to support the transport. Doing so can make transports run somewhat faster although replacing a 10 Mbit network with 100 Mbit is probably far more effective. Serialization is not the fastest transport mechanism but it's not that bad. And it is quite handy since you use it without writing any code. Also see the RMI and Object Serialization FAQ |
||||||||
| RMI has been also used as a frontline server to connect with Java Applets.
Write
high-performance RMI servers and Swing clients by Andy Krumel,
Mar 26, 1999 from JavaWorld explains how to make RMI efficiently communicate with an applet. It's limited here
by firewalls. However, RMI when used with servlets is highly adaptable. Randolph Kahle presents an overview and
applet example in Create Distributed Apps with RMI Feb 1998,
Java-Pro. Ted Stockwell's RMI on the Web Servlet Central, Mar 99 shows how to use servlets in Java 2 with RMI to tunnel between the browser and an RMI server. The example extends Sun's article Creating a Custom RMI Socket Factory. |
||||||||
| RMI's only limitation used to be that you could only call other Java applications
with it. No longer. Now Sun and IBM have jointly published RMI-IIOP. Based on a prototype developed by Jeff Nelson,
RMI-IIOP can be run across IIOP which means it can communicate with external CORBA (non-Java) components. Nelson's
protoype was published a series of articles: proof-of-concept, interoperability and distributed garbage collection in
Java Developers' Journal in August through October 1997. To use RMI-IIOP, you need to download it from Sun here. IBM provides a sample program here called "Space Conquest." and there is a tuturial in Sun's RMI-IIOP Programmer's Guide. Akira Andoh and Simon Nash, JavaWorld Dec 1999 compare RMI-IIOP capabilities with CORBA in their article called RMI-IIOP Tutorial. Bryan Morgan shows how to implement the same application in both RMI before RMI-IIOP and in CORBA and compares what the two capabilities were in Java 1.2 extends Java's distributed object capabilities Apr 1998, JavaWorld. |
||||||||
| Berkeley NinjaRMI |
Matt Welsh presents this introduction and tutorialfor using UC Berkeley's freeware Ninja RMI. There are two projects Keiretsu an Instant Messaging Service and iSpace a service architecture that are built on Ninja technology. | |||||||
| Weblogic RMI |
Bea Systems provides this guide called Using Weblogic RMI. Also take a look at the examples.cluster.rmi package. | |||||||
| Whitepark SmartStubs |
Whitepark who provides an RMI alternative called SmartStubs also provide several RMI Examples. The code can be used with either Sun's RMI or SmartStubs. | |||||||
| Use JNDI to look up servers in the RMI Registry as explained in Sun's RMI
Registry Service Provider page (see also: Java Skyline: Learn JNDI). Irving Salisbury explains how to use RMI to send a file in RMI allows you to write files to a Server by JavaWorld May 1997. |
||||||||
| Write
high-performance RMI servers and Swing clients by Andy Krumel,
JavaWorld Mar 1999 provides an example that demonstrates how to reduce thread synchronization in an RMI application.
Web Monkey presents Writing Chat Systems with Java 1.1's RMI, July 1997. And Michael Elhadad presents a RMI print server example for his Software Engineering course at Ben Gurion University. See also the RMI User's Log Archive for discussion material on RMI. To subscribe to RMI USERS send the message subscribe rmi-users to listserv@java.sun.com. |
||||||||
| Highly Recommended:
Mastering
RMI by Rickard Oberg, Wiley, Mar, 2001. Also see Rikard's website
DreamBean for Java Naming
Provider - an easy implementation of the RMI Registry that both
enables a hierarchial RMI registratoin and operates dynamically - not requiring RMIC. RMI source code is otherwise
not affected. Highly Recommended: One great starting place for learning RMI and other Java related component technologies is the book Client/Server Programming with Java and CORBA 2nd Ed, by Robert Orfali and Dan Harkey. Hardly limited to CORBA, the book provides easy to follow training materials for RMI, DCOM, JDBC, and EJB. The CountRMI example from the book appears here. Information about the book can be found at San Jose State: http://www.corbajava.engr.sjsu.edu. |
||||||||
|
|
||||||||