edu.wpi.prc.example.java.common
Class Server

java.lang.Object
  extended by edu.wpi.prc.example.java.common.Server

public class Server
extends java.lang.Object

The Server class is responsible for initializing, starting, and stopping an XML-RPC server.

Author:
James Baldassari

Field Summary
private static int EXIT_ERROR
           
private  boolean isRunning
           
private  int port
           
private  org.apache.xmlrpc.WebServer xmlrpcServer
           
 
Constructor Summary
Server(int port)
          Constructor that takes the port number on which to listen.
 
Method Summary
private  void initXmlRpcServer()
          Initializes and starts the XML-RPC server.
 boolean isRunning()
           
 void registerRPCHandler(java.lang.String handlerName, java.lang.Object rpcHandler)
          Registers the given RPC handler object with the XML-RPC server.
 boolean shutdown()
          Performs any tasks necessary to clearnly shut down the server.
 void start()
          Starts the XML-RPC server and begins handling requests.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXIT_ERROR

private static final int EXIT_ERROR
See Also:
Constant Field Values

port

private int port

xmlrpcServer

private org.apache.xmlrpc.WebServer xmlrpcServer

isRunning

private boolean isRunning
Constructor Detail

Server

public Server(int port)
Constructor that takes the port number on which to listen. Initializes the XML-RPC server.

Parameters:
port - The port number on which to listen for XML-RPC requests.
Method Detail

initXmlRpcServer

private void initXmlRpcServer()
Initializes and starts the XML-RPC server.


registerRPCHandler

public void registerRPCHandler(java.lang.String handlerName,
                               java.lang.Object rpcHandler)
Registers the given RPC handler object with the XML-RPC server.

Parameters:
handlerName - The name of the handler. All RPCs will be prefixed with this name. Example: in the call "sciapp.computeResult" "sciapp" is the name of the handler and "computeResult" is the name of the method to call inside that handler.
rpcHandler - The object containing the handler methods.

isRunning

public boolean isRunning()
Returns:
Returns true if the server is running, false otherwise.

start

public void start()
Starts the XML-RPC server and begins handling requests.


shutdown

public boolean shutdown()
Performs any tasks necessary to clearnly shut down the server.

Returns:
Returns true.