Package org.apache.xmlrpc.client
Class TimingOutCallback
java.lang.Object
org.apache.xmlrpc.client.TimingOutCallback
- All Implemented Interfaces:
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
Nested ClassesModifier and TypeClassDescriptionstatic classThis exception is thrown, if the request times out. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTimingOutCallback(long pTimeout) Waits the specified number of milliseconds for a response. -
Method Summary
Modifier and TypeMethodDescriptionvoidhandleError(XmlRpcRequest pRequest, Throwable pError) Something went wrong, handle error.voidhandleResult(XmlRpcRequest pRequest, Object pResult) Call went ok, handle result.Called to wait for the response.
-
Field Details
-
timeout
private final long timeout -
result
-
error
-
responseSeen
private boolean responseSeen
-
-
Constructor Details
-
TimingOutCallback
public TimingOutCallback(long pTimeout) Waits the specified number of milliseconds for a response.
-
-
Method Details
-
waitForResponse
Called to wait for the response.- Throws:
InterruptedException- The thread was interrupted.TimingOutCallback.TimeoutException- No response was received after waiting the specified time.Throwable- An error was returned by the server.
-
handleError
Description copied from interface:AsyncCallbackSomething went wrong, handle error.- Specified by:
handleErrorin interfaceAsyncCallback- Parameters:
pRequest- The request being performed.pError- The error being thrown.
-
handleResult
Description copied from interface:AsyncCallbackCall went ok, handle result.- Specified by:
handleResultin interfaceAsyncCallback- Parameters:
pRequest- The request being performed.pResult- The result object, which was returned by the server.
-