|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
T
- Type of object returned by the Future.get()
public interface AsyncHandler<T>
An asynchronous handler or callback which gets invoked as soon as some data is available when
processing an asynchronous response.
Callback methods get invoked in the following order:
onStatusReceived(HttpResponseStatus)
,onHeadersReceived(HttpResponseHeaders)
,onBodyPartReceived(HttpResponseBodyPart)
, which could be invoked multiple times,onCompleted()
, once the response has been fully read.AsyncHandler.STATE.ABORT
from any of those callback methods will interrupt asynchronous response
processing, after that only onCompleted()
is going to be called.
AsyncHandler aren't thread safe, hence you should avoid re-using the same instance when doing concurrent requests.
As an exmaple, the following may produce unexpected results:
It is recommended to create a new instance instead.AsyncHandler ah = new AsyncHandler() {....}; AsyncHttpClient client = new AsyncHttpClient(); client.prepareGet("http://...").execute(ah); client.prepareGet("http://...").execute(ah);
Nested Class Summary | |
---|---|
static class |
AsyncHandler.STATE
|
Method Summary | |
---|---|
AsyncHandler.STATE |
onBodyPartReceived(HttpResponseBodyPart bodyPart)
Invoked as soon as some response body part are received. |
T |
onCompleted()
Invoked once the HTTP response processing is finished. |
AsyncHandler.STATE |
onHeadersReceived(HttpResponseHeaders headers)
Invoked as soon as the HTTP headers has been received. |
AsyncHandler.STATE |
onStatusReceived(HttpResponseStatus responseStatus)
Invoked as soon as the HTTP status line has been received |
void |
onThrowable(Throwable t)
Invoked when an unexpected exception occurs during the processing of the response. |
Method Detail |
---|
void onThrowable(Throwable t)
t
- a Throwable
AsyncHandler.STATE onBodyPartReceived(HttpResponseBodyPart bodyPart) throws Exception
bodyPart
- response's body part.
AsyncHandler.STATE
telling to CONTINUE or ABORT the current processing.
Exception
- if something wrong happensAsyncHandler.STATE onStatusReceived(HttpResponseStatus responseStatus) throws Exception
responseStatus
- the status code and test of the response
AsyncHandler.STATE
telling to CONTINUE or ABORT the current processing.
Exception
- if something wrong happensAsyncHandler.STATE onHeadersReceived(HttpResponseHeaders headers) throws Exception
headers
- the HTTP headers.
AsyncHandler.STATE
telling to CONTINUE or ABORT the current processing.
Exception
- if something wrong happensT onCompleted() throws Exception
Future
Exception
- if something wrong happens
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |