This directory contains the source code to the RMI examples from
the slides.

To customize the source code for the environment you're using it in
you will need to:

  - Edit the String "URL" in the class tlh20.rmi.Phonetic so that
    it refers to the machine that you're running the RMI registry
    on and so that the service name is prefixed with your own
    user ID.

To build the example code:

  - Compile all three files in the tlh20.rmi package.  You should
    get three class files: Phonetic.class PhoneticClient.class and
    PhoneticServer.class

  - Create a directory visible to a web server in which to deposit
    the code that the client will need to download in order to
    contact the server.  On thor and the PWF Linux machines the
    files under ~/public_html are all accessible through the web
    servers that run on those machines.  In the notes I used the
    location ~/public_html/java/classes/.  Set the shell variable
    PUBCLASSES to refer to this location:

      mkdir -p ~/public_html/java/classes
      export PUBCLASSES=~/public_html/java/classes/

  - Compile the stub class from the server, placing the result under
    PUBCLASSES:
    
      rmic -v1.2 -d $PUBCLASSES tlh20.rmi.PhoneticServer

  - Copy the class file for the remote interface into the corresponding
    location under PUBCLASSES:

      cp tlh20/rmi/Phonetic.class $PUBCLASSES/tlh20/rmi/

PWF Linux only: start the RMI registry

  - If the client is to be able to download the stub class successfully
    then you need to make sure that the registry cannot access the
    stub class through the ordinary file system, e.g.:

      cd /
      export CLASSPATH=/
      java -Djava.rmi.server.logCalls=true sun.rmi.registry.RegistryImpl

Start the server, setting the CODEBASE shell variable to refer to the URL
from which the stub definition is available:

      export CODEBASE=http://pccl061.pwf.cl.cam.ac.uk/~tlh20/java/classes/
      export PUBCLASSES=~/public_html/java/classes/
      export CLASSPATH=$PUBCLASSES:.
      java -Djava.security.policy=security.policy -Djava.rmi.server.codebase=$CODEBASE tlh20.rmi.PhoneticServer

Start the client:

      java -Djava.security.policy=security.policy tlh20.rmi.PhoneticClient

TLH 16/11/2001
