Java Technology Home Page
A-Z Index

Java Developer Connection(SM)
Online Training

Downloads, APIs, Documentation
Java Developer Connection
Tutorials, Tech Articles, Training
Online Support
Community Discussion
News & Events from Everywhere
Products from Everywhere
How Java Technology is Used Worldwide
 

Fundamentals of RMI

Bootstrap Example

by jGuru

[Help | API Docs | Short Course| Exercises]


This exercise has three components: bootstrap HTTP Server, bootstrap RMI Server and bootstrap RMI Client. They highlight how RMI supports the distributed, on-demand loading of class files via FTP and HTTP servers.

To start with, you run a simple, lightweight HTTP server. This server acts as the network server for the class files needed for the RMI Client and Server.

The lightweight HTTP server is implemented by two classes provided by Sun Microsystems. The file ClassLoader.java is an abstract class, and the file ClassFileLoader.java is the implementation class for the HTTP Server. This server is very simple and only delivers Java class files.

You have to place the HTTP Server files in a subdirectory different to the one containing the RMI Server and Client files. After compilation, start the HTTP Server from within its subdirectory and provide it a path parameter that tells the HTTP Server to deliver class files from the RMI server subdirectory.

Next, you create and run the bootstrap RMI Server for the bootstrap example. The server is very similar to other RMI Servers you have run. One of the main differences in this example is that the client code is located in the same directory as the server. Note that all of the files have already been created for you. It is up to the HTTP Server to deliver the client classes to the client computer.

Finally, you will create the RMI bootstrap loader program, RMIClientLoader.java. Make sure that this file is located in a separate directory from the ones containing the HTTP Server files and the RMI Client and Server files. The sole purpose of this program is to start and then request the 'real' client software from the network. The requests for classes are then serviced by the HTTP Server that you ran earlier in the exercise.

One of the challenges of building a bootstrap program is passing start-up information from the bootstrap portion of the system to the real client code. The program uses a system property to store information that must be communicated to the real-client program.

Again, note that in this exercise it is important to run the programs in the following sequence:

  1. Bootstrap HTTP Server
  2. Bootstrap RMI Server
  3. Bootstrap RMI Client

This exercise is an example of the "bootstrap" model of distribution of classes. This is covered in the Automatic Distribution of classes section of the Course Notes.

Resources

Back to Top

Tasks


  1. Save the two program files and the runhttp.bat command file into some directory and compile the HTTP Server files

  2. Start the HTTP Server

  3. Compile all the class files for the client and server

  4. Create the stub and skeleton files for the remote object implementation

  5. Run the RMI server program

  6. Compile the class files for the client bootstrap loader program

  7. Edit the runclient.bat command file to include the name of your computer

  8. Run the runclient.bat command file.

Where help exists, the task numbers above are linked to the step-by-step help page.

Solution Source

Demonstration

When the HTTP Server is run in a console window, the output will be:

ClassFileServer started...

As the client runs and downloads files from the HTTP Server, notice that the HTTP Server indicates the files it reads from the disk. The first program it delivers is the client program itself, RMIClient. After that, it delivers stub files and other classes needed by the client.

Next, when the RMI Server is run in a console window, the output will be:

Registry created on host computer localhost on port 10009
Remote Hello implementation object created
Bindings Finished, waiting for client requests.

Finally, when the client bootstrap program is run in its console window, the output will be:

http://ROSA:2002/
After loading Client Class
Message from Server: Hello!
MessageObject: Class Number is #0 Object Number is #0
MessageObject: Class Number is #0 Object Number is #1
MessageObject: Class Number is #0 Object Number is #2
MessageObject: Class Number is #0 Object Number is #3
MessageObject: Class Number is #0 Object Number is #4
MessageObject: Class Number is #0 Object Number is #5
MessageObject: Class Number is #0 Object Number is #6
MessageObject: Class Number is #0 Object Number is #7
MessageObject: Class Number is #0 Object Number is #8
MessageObject: Class Number is #0 Object Number is #9

At the same time, you will notice the following output on the RMI Server console:

MessageObject: Class Number is #0 Object Number is #0
MessageObject: Class Number is #1 Object Number is #1
MessageObject: Class Number is #2 Object Number is #2
MessageObject: Class Number is #3 Object Number is #3
MessageObject: Class Number is #4 Object Number is #4
MessageObject: Class Number is #5 Object Number is #5
MessageObject: Class Number is #6 Object Number is #6
MessageObject: Class Number is #7 Object Number is #7
MessageObject: Class Number is #8 Object Number is #8
MessageObject: Class Number is #9 Object Number is #9

Next Magercise

Exercises

Short Course

Feedback

Back to Top

Copyright 1996-2000 jGuru.com. All Rights Reserved.


[ This page was updated: 25-Feb-2000 ]
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's AT&T Direct Access Number first.
Sun Microsystems, Inc.
Copyright © 1995-2000 Sun Microsystems, Inc.
All Rights Reserved. Terms of Use. Privacy Policy.