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

java.lang.Object
  extended by edu.wpi.prc.example.java.common.Client
Direct Known Subclasses:
ScienceApplicationClient, ValidatorClient, WorkGeneratorClient

public class Client
extends java.lang.Object

The client class is responsible for executing XML-RPCs.

Author:
James Baldassari

Field Summary
private static int EXIT_ERROR
           
private static int RETRY_DELAY
           
private  java.lang.String serverAddress
           
private  org.apache.xmlrpc.XmlRpcClient xmlrpcClient
           
 
Constructor Summary
Client(java.lang.String serverAddress)
          Constructor specifying the address of the remote XML-RPC server.
 
Method Summary
 java.lang.Object executeRPC(java.lang.String rpcName, java.util.Vector params)
          Executes an XML-RPC.
 java.lang.Object executeRPCUntilSuccess(java.lang.String rpcName, java.util.Vector params, java.lang.String errorMessage)
          Keeps trying to execute the RPC until it is successful.
private  void initXmlRpcClient()
          Initializes the XML-RPC client used for communicating with the project client.
 void setServerAddress(java.lang.String serverAddress)
          Sets the address of the remote XML-RPC server.
 
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

RETRY_DELAY

private static final int RETRY_DELAY
See Also:
Constant Field Values

xmlrpcClient

private org.apache.xmlrpc.XmlRpcClient xmlrpcClient

serverAddress

private java.lang.String serverAddress
Constructor Detail

Client

public Client(java.lang.String serverAddress)
Constructor specifying the address of the remote XML-RPC server.

Parameters:
serverAddress - The address (host:port) of the remote XML-RPC server.
Method Detail

initXmlRpcClient

private void initXmlRpcClient()
Initializes the XML-RPC client used for communicating with the project client.


setServerAddress

public void setServerAddress(java.lang.String serverAddress)
Sets the address of the remote XML-RPC server.

Parameters:
serverAddress - The address (host:port) of the remote XML-RPC server.

executeRPC

public java.lang.Object executeRPC(java.lang.String rpcName,
                                   java.util.Vector params)
                            throws org.apache.xmlrpc.XmlRpcException,
                                   java.io.IOException
Executes an XML-RPC.

Parameters:
rpcName - The name of the RPC to execute.
params - The parameters to the RPC.
Returns:
Returns the return value of the RPC.
Throws:
org.apache.xmlrpc.XmlRpcException
java.io.IOException

executeRPCUntilSuccess

public java.lang.Object executeRPCUntilSuccess(java.lang.String rpcName,
                                               java.util.Vector params,
                                               java.lang.String errorMessage)
                                        throws RPCHandlerException
Keeps trying to execute the RPC until it is successful. Note that this does not necessarily mean that no errors occurred. It simply means that the connection to the XML-RPC server was successful, and the XML-RPC call was attempted. An RPCHandlerException will be thrown if any XML-RPC errors occur, such as if the given RPC was not found on the server, or if the remote RPC handler threw an Exception while executing the RPC.

Parameters:
rpcName - The name of the XML-RPC to execute.
params - The parameters to pass to the XML-RPC. This must not be null.
errorMessage - The heading text to use when printing out any error messages that occur.
Returns:
Returns the value returned by the XML-RPC call. This must be cast to the expected type.
Throws:
org.apache.xmlrpc.XmlRpcException
RPCHandlerException