edu.wpi.prc.server
Class PRCServer

java.lang.Object
  extended by edu.wpi.prc.server.PRCServer
All Implemented Interfaces:
java.lang.Runnable

public class PRCServer
extends java.lang.Object
implements java.lang.Runnable


Field Summary
private static int EXIT_ERROR
           
private static int EXIT_SUCCESS
           
private static boolean isRunning
           
private static boolean isTransitionerRunning
           
private static PRCServer prcServer
           
private  ServerRPCHandler rpcHandler
           
private  Transitioner transitioner
           
private static java.util.concurrent.Semaphore transitionerSemaphore
           
private static boolean waitForTransactions
           
private  org.apache.xmlrpc.WebServer xmlrpcServer
           
 
Constructor Summary
private PRCServer()
          Private constructor prevents explcit instantiation of the PRCServer class.
 
Method Summary
 ServerRPCHandler getRPCHandler()
           
 Transitioner getTransitioner()
           
 java.util.concurrent.Semaphore getTransitionerSemaphore()
           
 org.apache.xmlrpc.WebServer getXmlrpcServer()
           
 void initiateShutdown()
          Performs any tasks necessary to clearnly shut down the server.
private  void initXmlRpcServer()
          Initializes and starts the XML-RPC server.
static PRCServer instance()
           
 boolean isRunning()
           
 boolean isTransitionerRunning()
           
static void main(java.lang.String[] args)
          Controls the server.
 void run()
          Starts the XML-RPC server and begins handling client requests.
 void setWaitForTransactions(boolean waitForTransactions)
           
 void shutdown()
          Shuts down the server when it is safe to do so.
 void shutdownTransitioner(boolean waitForTransactions)
          Cleanly shuts down the transitioner.
 void switchToLocalTransitioner()
          Switches the current transitioner to a LocalTransitioner.
 void switchToRemoteTransitioner()
          Switches the current transitioner to a RemoteTransitioner.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

prcServer

private static PRCServer prcServer

EXIT_SUCCESS

private static final int EXIT_SUCCESS
See Also:
Constant Field Values

EXIT_ERROR

private static final int EXIT_ERROR
See Also:
Constant Field Values

transitioner

private Transitioner transitioner

rpcHandler

private final ServerRPCHandler rpcHandler

xmlrpcServer

private org.apache.xmlrpc.WebServer xmlrpcServer

isRunning

private static boolean isRunning

isTransitionerRunning

private static boolean isTransitionerRunning

waitForTransactions

private static boolean waitForTransactions

transitionerSemaphore

private static final java.util.concurrent.Semaphore transitionerSemaphore
Constructor Detail

PRCServer

private PRCServer()
Private constructor prevents explcit instantiation of the PRCServer class. Initializes the server componenets.

Method Detail

initXmlRpcServer

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


getTransitioner

public Transitioner getTransitioner()
Returns:
Returns the transitioner used by this project.

setWaitForTransactions

public void setWaitForTransactions(boolean waitForTransactions)
Parameters:
waitForTransactions - True if the server should wait for all transitioner transactions to complete before shutting down, false otherwise.

getTransitionerSemaphore

public java.util.concurrent.Semaphore getTransitionerSemaphore()
Returns:
Returns the transitioner semaphore.

getRPCHandler

public ServerRPCHandler getRPCHandler()
Returns:
Returns the RPC handler.

getXmlrpcServer

public org.apache.xmlrpc.WebServer getXmlrpcServer()
Returns:
Returns the XML-RPC server.

isRunning

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

isTransitionerRunning

public boolean isTransitionerRunning()
Returns:
Returns true if the transitioner is running, false otherwise.

run

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

Specified by:
run in interface java.lang.Runnable

switchToLocalTransitioner

public void switchToLocalTransitioner()
Switches the current transitioner to a LocalTransitioner. NOTE: This functionality is not fully supported and is intended to be a future feature.


switchToRemoteTransitioner

public void switchToRemoteTransitioner()
Switches the current transitioner to a RemoteTransitioner. NOTE: This functionality is not fully supported and is intended to be a future feature.


initiateShutdown

public void initiateShutdown()
Performs any tasks necessary to clearnly shut down the server.


shutdownTransitioner

public void shutdownTransitioner(boolean waitForTransactions)
Cleanly shuts down the transitioner.


shutdown

public void shutdown()
Shuts down the server when it is safe to do so. This method should never be called directly. Instead, initiateShutdown() should be called, which will cause the main() to call this method.


instance

public static PRCServer instance()
Returns:
Returns the singleton instance of the PRCServer class.

main

public static void main(java.lang.String[] args)
Controls the server.

Parameters:
args - Command-line arguments.