public class TimingOutCallback extends 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."); }
Modifier and Type | Class and Description |
---|---|
static class |
TimingOutCallback.TimeoutException
This exception is thrown, if the request times out.
|
Constructor and Description |
---|
TimingOutCallback(long pTimeout)
Waits the specified number of milliseconds for a response.
|
Modifier and Type | Method and Description |
---|---|
void |
handleError(XmlRpcRequest pRequest,
Throwable pError)
Something went wrong, handle error.
|
void |
handleResult(XmlRpcRequest pRequest,
Object pResult)
Call went ok, handle result.
|
Object |
waitForResponse()
Called to wait for the response.
|
public TimingOutCallback(long pTimeout)
public Object waitForResponse() throws Throwable
InterruptedException
- The thread was interrupted.TimingOutCallback.TimeoutException
- No response was received after waiting the specified time.Throwable
- An error was returned by the server.public void handleError(XmlRpcRequest pRequest, Throwable pError)
AsyncCallback
handleError
in interface AsyncCallback
pRequest
- The request being performed.pError
- The error being thrown.public void handleResult(XmlRpcRequest pRequest, Object pResult)
AsyncCallback
handleResult
in interface AsyncCallback
pRequest
- The request being performed.pResult
- The result object, which was returned by the server.Copyright © 2001–2016 The Apache Software Foundation. All rights reserved.