Getting a hold RMI

You are given sample Treasure object and Site Manager code. First run the code to get a hold on the problem. Here's what you do.
  1. Change SiteConfig.java for your current configuration.
    1. Reduce the number of sites to 2. Change the field NUMBER_OF_SITES to 2. THIS IS ONLY FOR TESTING. YOUR FINAL CODE SHOULD RUN ON FIVE SITES.
    2. Choose a random number between 2000 and 3999. Initialize the RMI_PORT field to this number. Keep this number in mind.
    3. Initialize the RMI_SERVER field to your current server name.
  2. Compile the code. You should use Java 1.1 or above.
        javac SiteConfig.java
        javac SiteImpl.java
        rmic SiteImpl
        javac Treasure.java
    
  3. Start the RMI Registry. For this, type
        rmiregistry <port> &
    
    where <port> is the number you choose in step 1.2 above.
  4. Keep three windows open. In each window, type one of the following commands.
    java SiteImpl Site0
    java SiteImpl Site1
    java Treasure Site0
    
    Now the Treasure object is launched from Site0 and it bounces between Sites 0 and 1 for a while before stopping.

What does the code contain?
  1. SiteConfig contains the configuration parameters like RMI server name, port numbers, etc.
  2. SiteImpl is the Site Manager. It takes a command line argument which determines the site name.
  3. Treasure is the Treasure object. It takes a command line argument which is the name of its first destination. After that, it randomly hops between sites.

What to add?

This is the basic code for the Site Manager and the Treasure object. In the example code, the Site Manager does not keep track of entry and exit of Treasure. It also does not handle synchronization problems. You should address these issues.

You should also write the Player, take care of reflection, etc.

More information

The best place to look for information is java.sun.com. In particular, you can check the tutorials on RMI and reflection.

You can also study some example code from Java Examples in a Nutshell. Examples 15-1 to 15-7 pertain to RMI and Examples 12-1 and 12-2 pertain to Reflection.