public class HttpMultiRequest extends Object implements HttpResponseReceiver<Object>
HttpMultiRequest executes arbitrary many (but more than 1 required)
HttpRequests and waits for therer responses before the
HttpMultiResponseReceiver gets notified about the success by calling
HttpMultiResponseReceiver.onSuccessful(HttpResponse...). The order of
the responses is equivalent to the order of HttpRequests. If one
HttpRequest will fail then the complete HttpMultiRequest will
fail by calling
HttpMultiResponseReceiver.onFailure(HttpRequest, Exception)| Constructor and Description |
|---|
HttpMultiRequest(HttpKit httpKit)
Creates a new
HttpMultiRequest but does not start it |
HttpMultiRequest(HttpKit httpKit,
HttpMultiResponseReceiver receiver,
HttpRequest... requests)
Creates a new
HttpMultiRequest with the given parameters and
starts it |
HttpMultiRequest(HttpKit httpKit,
HttpMultiResponseReceiver receiver,
List<HttpRequest> requests)
Creates a new
HttpMultiRequest with the given parameters and
starts it |
| Modifier and Type | Method and Description |
|---|---|
<T> HttpResponse<T> |
getResponse(int index)
Get the responses according the index (0...n), where the index is
equivalent to the order of the requ
|
void |
onFailure(HttpRequest req,
Exception e)
Called when the http request could not be executed successfully, because
an
Exception has occurred while sending the http request |
void |
onSuccess(HttpResponse<Object> res)
Called when the Http request has returned a result
|
HttpMultiRequest |
setResponseReceiver(HttpMultiResponseReceiver receiver) |
void |
start(HttpRequest... requests) |
void |
start(List<HttpRequest> requests)
Start
|
public HttpMultiRequest(HttpKit httpKit, HttpMultiResponseReceiver receiver, HttpRequest... requests)
HttpMultiRequest with the given parameters and
starts itpublic HttpMultiRequest(HttpKit httpKit, HttpMultiResponseReceiver receiver, List<HttpRequest> requests)
HttpMultiRequest with the given parameters and
starts itpublic HttpMultiRequest(HttpKit httpKit)
HttpMultiRequest but does not start itpublic HttpMultiRequest setResponseReceiver(HttpMultiResponseReceiver receiver)
public void start(HttpRequest... requests)
public void start(List<HttpRequest> requests)
public <T> HttpResponse<T> getResponse(int index)
public void onSuccess(HttpResponse<Object> res)
HttpResponseReceiveronSuccess in interface HttpResponseReceiver<Object>public void onFailure(HttpRequest req, Exception e)
HttpResponseReceiverException has occurred while sending the http requestonFailure in interface HttpResponseReceiver<Object>req - The HttpRequest that have caused the errore - The exception that was thrown while executing the
HttpRequestCopyright © 2015 Hannes Dorfmann. All rights reserved.