Hello!

I'm taking an advanced course in Java Networking, and I have an assignment where I am to create distributed application that acts as a marketplace where clients can buy and sell items. The task is focused on getting to understand RMI, and should be built without a GUI.

Given is a bank interface and an implementation class that implements that bank interface, as well as a server that registers the bank to the RMI-registry, and a client class that communicates with the bank remote instance.

The general idea is that I shall implement a marketplace on which the client can register/unregister, and buy/sell items of a non specific type. When an item is bought, the client who is the seller should be notified with an RMI callback function, and the marketplace should make a transaction in the bank to/from the buyer/seller.

So, what is my problem?
I'm having a hard time understanding the correct way to structure this application, aswell as where I am supposed to use the RMI calls. The existing client can communicate with the bank, and I have implemented a marketplace that looks somewhat the below class diagram shows.

Structure of a distributed application using RMI-rmiexample.png
The UML may not properly describe my structure since UML isn't my strongest competence...

This is how I was thinking of implementing my application.

The client registers an account with the bank and deposits some money to it, using RMI, Client -> Bank, Client -> Account.
The client then registers to the marketplace using RMI, Client -> Marketplace, and the marketplace makes sure that the client has a bank account, Marketplace -> Bank.
The client registers an item to be sold using RMI, Client -> Marketplace, the marketplace creates a new item and places it in a list of items to be sold.
The client buys an item from the marketplace, Client -> Marketplace, marketplace checks that the buyer has money, Marketplace -> Bank, and then makes the transactions.
The marketplace calls the notifyItemSold() using RMI, Marketplace -> Client.

So my questions are as follows:

  1. Would this be a proper way of using RMI to build a distributed application, where I also use RMI to communicate between the Marketplace and the Bank, or is this an unnecessary complicated structure?
  2. Must the Client interface also implement the Remote interface, so that I can create a "proxy" client on the Marketplace side, to invoke the method notifyItemSold()?
  3. What is a RMI callback function really? Is it just the fact the client side is an implementation of the Remote interface, and thus makes it possible to create a remote instance of that too, or is there some magic callback function that I have missed?



Any assistance to make the concepts of RMI a bit more clear would be helpful!
Thank you,
Z


(Note: I wasn't sure if I were to put this in Advanced Java or Networking. I apologize if it's misplaced!)