org.apache.xmlrpc.client
Class TimingOutCallback

java.lang.Object
  extended by org.apache.xmlrpc.client.TimingOutCallback
All Implemented Interfaces:
AsyncCallback

public class TimingOutCallback
extends java.lang.Object
implements AsyncCallback

A callback object that can wait up to a specified amount of time for the XML-RPC response. Suggested use is as follows:

   // Wait for 10 seconds.
   TimingOutCallback callback = new TimingOutCallback(10 * 1000);
   XmlRpcClient client = new XmlRpcClient(url);
   client.executeAsync(methodName, aVector, callback);
   try {
       return callback.waitForResponse();
   } catch (TimeoutException e) {
       System.out.println("No response from server.");
   } catch (Exception e) {
       System.out.println("Server returned an error message.");
   }
 


Nested Class Summary
static class TimingOutCallback.TimeoutException
          This exception is thrown, if the request times out.
 
Constructor Summary
TimingOutCallback(long pTimeout)
          Waits the specified number of milliseconds for a response.
 
Method Summary
 void handleError(XmlRpcRequest pRequest, java.lang.Throwable pError)
          Something went wrong, handle error.
 void handleResult(XmlRpcRequest pRequest, java.lang.Object pResult)
          Call went ok, handle result.
 java.lang.Object waitForResponse()
          Called to wait for the response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimingOutCallback

public TimingOutCallback(long pTimeout)
Waits the specified number of milliseconds for a response.

Method Detail

waitForResponse

public java.lang.Object waitForResponse()
                                 throws java.lang.Throwable
Called to wait for the response.

Throws:
java.lang.InterruptedException - The thread was interrupted.
TimingOutCallback.TimeoutException - No response was received after waiting the specified time.
java.lang.Throwable - An error was returned by the server.

handleError

public void handleError(XmlRpcRequest pRequest,
                        java.lang.Throwable pError)
Description copied from interface: AsyncCallback
Something went wrong, handle error.

Specified by:
handleError in interface AsyncCallback
Parameters:
pRequest - The request being performed.
pError - The error being thrown.

handleResult

public void handleResult(XmlRpcRequest pRequest,
                         java.lang.Object pResult)
Description copied from interface: AsyncCallback
Call went ok, handle result.

Specified by:
handleResult in interface AsyncCallback
Parameters:
pRequest - The request being performed.
pResult - The result object, which was returned by the server.


Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.