Class SingleServerWrapper

All Implemented Interfaces:
InteractiveTaskServer, java.rmi.Remote, java.io.Serializable

public class SingleServerWrapper
extends java.rmi.server.UnicastRemoteObject
implements InteractiveTaskServer

This wrapper simplifies the process of making your own server. It hides all the ugly RMI calls and allows you to concentrate on implementing the main ITServer methods. It takes an InteractiveTaskServer class through the command line, loads it, and does the necesary RMI binding.

See Also:
Serialized Form

Field Summary
protected  java.lang.String bindingName
protected  int bindingPort
protected static int DEFAULT_BINDING_PORT
protected  InteractiveTaskServer inITS
Fields inherited from class java.rmi.server.RemoteObject
Constructor Summary
SingleServerWrapper(InteractiveTaskServer inITS, java.lang.String bindingName)
          Creates a new instance of SingleServerWrapper
SingleServerWrapper(InteractiveTaskServer inITS, java.lang.String bindingName, int bindingPort)
          Creates a new instance of SingleServerWrapper
Method Summary
protected  void bindServer()
 java.lang.Object getID(java.lang.Object initialParameters)
          Called by clients the first time they connect.
 InteractiveTask getTask(java.lang.Object id)
          This will provide the client with the InteractiveTask it should run.
protected static void handleException(java.lang.Exception e)
 java.lang.Object interact(java.lang.Object ID, java.lang.Object clientTaskOutput)
          Called by clients when they wish to interact.
static void main(java.lang.String[] args)
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait

Field Detail


protected static final int DEFAULT_BINDING_PORT


protected InteractiveTaskServer inITS


protected java.lang.String bindingName


protected int bindingPort
Constructor Detail


public SingleServerWrapper(InteractiveTaskServer inITS,
                           java.lang.String bindingName,
                           int bindingPort)
                    throws java.rmi.RemoteException
Creates a new instance of SingleServerWrapper


public SingleServerWrapper(InteractiveTaskServer inITS,
                           java.lang.String bindingName)
                    throws java.rmi.RemoteException
Creates a new instance of SingleServerWrapper
Method Detail


public static void main(java.lang.String[] args)
args - the command line arguments. The first argument should be the class name of your interactive task server class to be wrapping around. This class should either have a constructor with no arguments or in the case that extra command line arguments have been supplied, a constructor with a single paramater of type ArrayList which will include String objects representing the extra command line arguments. . The second argument should be the RMI binding name you wish to use, which is the name clients will refer to this server by.


protected static void handleException(java.lang.Exception e)


protected void bindServer()
                   throws java.rmi.RemoteException,


public java.lang.Object getID(java.lang.Object initialParameters)
                       throws java.rmi.RemoteException
Called by clients the first time they connect.
Specified by:
getID in interface InteractiveTaskServer
initialParameters - Initial parameters from client local configuration. The current client implementation, see InteractiveTaskClient, provides the ip address of the client and the command line paramaters used to launch the client. These are packaged in a Vector.
The ID of this client will from now on used for interaction with the server.


public InteractiveTask getTask(java.lang.Object id)
                        throws java.rmi.RemoteException
This will provide the client with the InteractiveTask it should run.
Specified by:
getTask in interface InteractiveTaskServer
id - The ID provided by the getID method by which the client will always refer to itself.
The task this client should run. This could be exactly the same as the one all other clients are running or tailored to this particular client.


public java.lang.Object interact(java.lang.Object ID,
                                 java.lang.Object clientTaskOutput)
                          throws java.rmi.RemoteException
Called by clients when they wish to interact.
Specified by:
interact in interface InteractiveTaskServer
ID - the client's ID
clientTaskOutput - the outputs of the client obtained by task.get( null ) on the client task
whatever should be sent into the client through task.set( )