Homework #2 - Java RMI Execution
Homework #2 - Java RMI Execution
In this homework, you are asked to develop Java programs for client and server sides that
enable the client programs to invoke methods of the object whose implementations reside on a
remote server. Suppose there is a bank in a city that has 100 accounts and each account has
at least $1,000 and at most $9,000. In addition, the bank has assets of exactly 500,000 dollars.
The server side of the application will be working on a remote machine and will respond to
the client’s invocation requests. For the time being, the clients will be able to see only the
balance in their account when they send the bank the account ID and a PIN number associated
with the account. The client program will invoke showBalance method of the object
BankAccount using RMI. Therefore, the server needs to have an implementation of the
following interface for BankAccount:
The client stub (proxy) will have to be generated by rmic and the client side has to access the
proxy in order to invoke the showBalance method. Note that you need to define two new
objects AccountID and PinNo, and make them available both to the server and the client.
1. Write the server side of the application, which implements the BankAccount
interface. The server application needs also to create 100 accounts and deposit a
random amount of money in the range of [$1,000, $9,000] to each so that the total
amount in the bank will be exactly 500,000 dollars and get ready for client
invocations.
2. Write the client side of the application, which passes an account ID and a PIN number
when invoking the BankAccount interface and prints the returned variable on the
screen.
3. Run the code on the same machine, all the Java class files are in the same directory.
(50 points)
4. Put client side and server side components on different machines and run the code.
(Note that you will need to put the copies of the proxy in the same directories as the
server and client sides) (15 points)
5. Client and server side components are on the same machine but in different
directories. Proxy must also be in a different directory other than the directories where
the server and client components are placed. (25 points)
6. Where do you think the proxy must be placed in order to have better flexibility? Think
of the situation when the server changes the proxy frequently and the client
subsequently has to download a new proxy for the same interface. Explain how would
you implement your solution? You do not have to actually implement your solution;
however make sure that it can be implemented with RMI. (5 points)
7. Which objects are passed-by-value and which of them by reference? (5 points).
8. Submit your homework to the assistant
9. Demonstrate to the assistant that your application is running correctly and satisfying
all the said requirements.