Welcome to jGuru.com exercises for the Fundamentals of RMI short
course.
These exercises illustrate the use of the Remote Method Invocation (RMI)
library for implementing distributed objects.
When you finish these exercises, you will have a good idea of the essential
concepts involved in building RMI-based distributed Java systems.
With this foundation, you will be able to design and implement
dsophisticated, multi-computer JavaTM
programs.
Exercise Outline
About Exercises
A jGuru exercise is a flexible exercise that provides varying levels
of help according to the student's needs. Some students may complete the
exercise using only the information and the task list in the exercise
body; some may want a few hints (Help); while others may want a step-by-step
guide to successful completion (Solution). Since complete solutions
are provided in addition to help, students can skip an exercise and still be
able to complete later exercises that required the skipped
one(s).
The Anatomy of an Exercise
Each exercise includes a list of any prerequisite exercises, a list
of skeleton code for you to start with, links to necessary API pages,
and a text description of the exercise's educational goal. In addition,
buttons link you to the following information:
-
Help: Gives you help or hints on the
current exercise, an annotated solution. For ease of use,
the task information is duplicated on the help page with the
actual help information indented beneath it.
-
Solution: The
<applet>
tag and Java source resulting in the expected behavior.
-
API Documentation: A link directly to
any necessary online API documentation.
Exercise Design Goals
There are three fundamental exercise types that you may encounter:
- "Blank
screen"
- You are confronted
with a "blank screen" and
you
create the entire desired functionality yourself.
-
Extension
- You extend the
functionality of an existing,
correctly-working program.
- Repair
- You repair undesirable behavior in an existing
program.
To make learning easier, exercises, where possible, address only
the specific technique being taught in that exercise. Irrelevant,
unrelated, and overly complex materials are avoided.
Where possible, exercises execute via the web. However, exercises
that must access Java features or library elements that could cause
security violations are not executed on the web.
-
UML Definition of RMI Example System
This exercise will introduce you to the definition of RMI remote services
using Java interfaces.
Educational goals:
-
Introduce the UML
Description of a banking system
-
Complete the Java
source code for the system interfaces
-
Simple Banking System
In this exercise you will run your first RMI system.
It is based on the Banking System that you started
in the previous exercise.
Educational goals:
-
Learn to run the RMI Registry as a separate process
-
Run a server that support remote RMI objects
-
Implement an RMI client that uses remote services.
-
RMI Parameters
When a remote method is called, parameters may be passed to the
remote object and a return value may be sent back to the calling program.
This exercise explores how RMI handles primitive data types, normal
local Java objects, and remote RMI objects as parameters and return values.
Educational goals:
-
Practice defining and
implementing remote interfaces and their implementations.
-
Learn how remote
objects and normal objects are passed as parameters.
-
RMI Client Callbacks
In some RMI systems, it will make sense for a server to make calls
to a client program.
This can be done using client-side callbacks.
It is very easy to build client-side callbacks with RMI.
One simply creates a client-side remote object and gives a reference
to it to the server.
The server then uses this remote reference to call into the client's
program.
Educational goals:
-
Learn how to create
client-side remote objects.
-
Prepare and export
remote objects that do not
directly extend
java.rmi.server.UnicastRemoteObject
-
Bootstrap Example
This exercise has three components: bootstrap HTTP Server, bootstrap RMI
Server and
bootstrap RMI Client. They will highlight how RMI supports the distributed,
on-demand loading of class files via FTP and HTTP servers.
To start with, you will first run a simple server that
delivers Java class files through the HTTP protocol.
Next, you will create and run the bootstrap RMI Server. The server is very
similar to other RMI Servers you have run.
One of the main differences in this example is that the RMI client
code is located in the same directory as the server.
It will be up to the HTTP Server to deliver the client classes
to the client computer.
Finally, you will create a very thin client program.
The sole purpose of this program is to start and then
request the 'real' client software from the network.
The requests for Java classes will be serviced by the
HTTP Server that you ran earlier in the exercise.
Educational goals:
-
Observe an HTTP Server supplying classes to an RMI system
-
Observe how to write a simple HTTP Server
-
Create and run an RMI Server program
-
Build a bootstrap program to load the client program over the network
-
Run the Bootstrap Client and observe how the HTTP Server program
reports which classes have been requested and supplied
-
Learn about the
java.rmi.server.codebase
system property
-
Distributed Garbage Collection
The Distributed Garbage Collector and the local Java garbage collector work
together to manage heap memory space in each JavaTM Virtual Machine1(JVM) that participate in
an RMI system.
In this exercise, you will have the opportunity to experiment with
an RMI Server and two RMI Clients to observe how memory is managed.
Educational goals:
-
Observe the behavior
of the Distributed Garbage Collector.
-
Observe the
interaction of the local and distributed garbage collectors.
-
Experiment with
different settings for the Java heap and notice
how it affects the operation of the two garbage collectors.
-
Serializing Remote Objects: Server
This exercise illustrates how to use the Delegation Pattern
to create a system that will allow a network service to migrate between
a local machine JVM and the remote server.
This is a simple version of a Delegation architecture.
More sophisticated architectures can be build by expanding on this example.
This is a two-part exercise.
Run the server first and then the client to complete the example.
Educational goals:
-
Understand how RMI
limits the ability to move remote objects between JVMs.
-
See how to use the
Delegation Pattern to overcome this limitation.
-
Serializing Remote Objects: Client
The client program will request both a remote reference to a service and a
local
copy of an object that implements the service.
Educational goals:
-
See how to build an
RMI client that uses either a remote reference to a service or a local
copy.
Copyright 1996-2000 jGuru.com. All Rights Reserved.
_______
1 As used on this web site, the terms "Java
virtual machine" or "JVM" mean a virtual machine for the Java
platform.