![]() ![]() ![]() |
|
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
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 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, 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:
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 TopTasks
Save the two program files and the
Compile all the class files for the client and server
Create the
Compile the class files for the client bootstrap loader program
Edit the
Run the 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, 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 MagerciseExercisesShort CourseFeedbackBack to TopCopyright 1996-2000 jGuru.com. All Rights Reserved. |