by
[Help |
API Docs |
Short Course|
Exercises]
This exercise leads you through the creation
of your first RMI system.
In this exercise, you will run the RMI Registry (which
will manage the publication of the RMI remote services),
run a server program that creates
the actual remote services, and finally,
finish coding the program BankUser, which will
use the RMI remote services.
Prerequisites
UML Definition of RMI Example System
Skeleton Code
Account.class
AccountImpl.class
AccountImpl_Stub.class
AccountImpl_Skel.class
BankManager.class
BankManagerImpl.class
BankManagerImpl_Stub.class
BankManagerImpl_Skel.class
Client.class
ClientImpl.class
ClientImpl_Stub.class
ClientImpl_Skel.class
NoCashAvailableException.class
BankSystemServer.class
BankUser.java
Tasks
1. Run the RMI Registry program.
2. Copy all the .class files to a directory.
3. Run the RMI server that hosts the remote service objects.
4. Create and run a program that will use the exported RMI services. Find out the owner of account 4461 and how much money is in it.
Where help exists, the task numbers above are linked to the
step-by-step help page.
When you finish this exercise, you will have run your first RMI system.
It consists of three major parts:
-
The RMI Registry that hold references to the remote services.
-
The RMI host server program that creates the remote services,
registers them with the registry and waits for client requests.
-
The RMI client program. A program that obtains references to remote
service object from the RMI registry and then uses those services.
Solution Source
Account.java
Account.class
AccountImpl.java
AccountImpl.class
AccountImpl_Stub.class
AccountImpl_Skel.class
BankManager.java
BankManager.class
BankManagerImpl.java
BankManagerImpl.class
BankManagerImpl_Stub.class
BankManagerImpl_Skel.class
BankUser.java
BankUser.class
Client.java
Client.class
ClientImpl.java
ClientImpl.class
ClientImpl_Stub.class
ClientImpl_Skel.class
NoCashAvailableException.java
NoCashAvailableException.class
BankSystemServer.java
BankSystemServer.class
Demonstration
When the RMI Registry and the RMI host sever program
are run, there is no observable behavior.
When the RMI client BankUser is run,
the console will display what ever messages you
include in the program.
The solution specifically displays:
Charlie's account has $600.00
Copyright 1996-2000 jGuru.com. All Rights Reserved.
|