|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jscience.computing.distributed.server.SingleServerWrapper
public class SingleServerWrapper
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.
SingleServerWrapper offers the possibility of forcing RMI traffic to go through a specified port. This is NOT the port of the RMI Registry which is at 1099 by default. RMI uses another port to handle connections with clients. This is the port which can be configured here. If ommited, the default Java behaviour is to pick a random port each time.
A SingleServerWrapper can be constructed through the command line passing the class name of the InteractiveTaskServer to load followed by the name by which it should be bound in the RMI Registry followed by Strings to be passed to the constructor of this class inside an ArrayList. A '-p' argument followed by an integer will define the handling port for RMI to use.
Alternately, a SingleServerWrapper Object can be created using the constructors directly and calling the bindServer method to bind it to the RMI Registry.
| Field Summary | |
|---|---|
protected java.lang.String |
bindingName
|
protected InteractiveTaskServer |
inITS
|
protected int |
trafficPort
|
| Constructor Summary | |
|---|---|
SingleServerWrapper(InteractiveTaskServer inITS,
java.lang.String bindingName)
Creates a new instance of SingleServerWrapper |
|
SingleServerWrapper(InteractiveTaskServer inITS,
java.lang.String bindingName,
int trafficPort)
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.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected InteractiveTaskServer inITS
protected java.lang.String bindingName
protected int trafficPort
| Constructor Detail |
|---|
public SingleServerWrapper(InteractiveTaskServer inITS,
java.lang.String bindingName)
throws java.rmi.RemoteException
inITS - InteractiveTaskServer object we wan't to bind using this wrapper.bindingName - Name under which to bind this server into the RMI Registry.
java.rmi.RemoteException
public SingleServerWrapper(InteractiveTaskServer inITS,
java.lang.String bindingName,
int trafficPort)
throws java.rmi.RemoteException
inITS - InteractiveTaskServer object we wan't to bind using this wrapper.bindingName - Name under which to bind this server into the RMI Registry.trafficPort - Port to use for all RMI traffic. This is different to the RMI Registry port which is 1099 by default.
java.rmi.RemoteException| 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.
A '-p' argument followed by an integer will define the handling port for RMI to use.protected static void handleException(java.lang.Exception e)
protected void bindServer()
throws java.rmi.RemoteException,
java.net.MalformedURLException,
java.io.IOException
java.rmi.RemoteException
java.net.MalformedURLException
java.io.IOException
public java.lang.Object getID(java.lang.Object initialParameters)
throws java.rmi.RemoteException
getID in interface InteractiveTaskServerinitialParameters - 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.
java.rmi.RemoteException - DOCUMENT ME!
public InteractiveTask getTask(java.lang.Object id)
throws java.rmi.RemoteException
getTask in interface InteractiveTaskServerid - The ID provided by the getID method by which the
client will always refer to itself.
java.rmi.RemoteException - DOCUMENT ME!
public java.lang.Object interact(java.lang.Object ID,
java.lang.Object clientTaskOutput)
throws java.rmi.RemoteException
interact in interface InteractiveTaskServerID - the client's IDclientTaskOutput - the outputs of the client obtained by task.get( null ) on the client task
java.rmi.RemoteException - DOCUMENT ME!
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||