org.apache.xmlrpc.client

Class TimingOutCallback

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, Throwable pError)
void
handleResult(XmlRpcRequest pRequest, Object pResult)
Object
waitForResponse()
Called to wait for the response.

Constructor Details

TimingOutCallback

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

Method Details

handleError

public void handleError(XmlRpcRequest pRequest,
                        Throwable pError)
Specified by:
handleError in interface AsyncCallback

handleResult

public void handleResult(XmlRpcRequest pRequest,
                         Object pResult)
Specified by:
handleResult in interface AsyncCallback

waitForResponse

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

Copyright © 2001-2007 Apache Software Foundation. All Rights Reserved.