Sending another asynchronous request from an AsyncHandler must be done using
another thread to avoid potential deadlock inside the AsyncHttpProvider
The recommended way is to use the ExecutorService from the AsyncHttpClientConfig:
@Override
public T onCompleted(Response response) throws Exception
{
asyncHttpClient.getConfig().executorService().execute(new Runnable()
{
public void run()
{
asyncHttpClient.prepareGet(...);
}
});
return T;
}
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AsyncCompletionHandler
public AsyncCompletionHandler()
onBodyPartReceived
public AsyncHandler.STATE onBodyPartReceived(HttpResponseBodyPart content)
throws Exception
- Invoked as soon as some response body part are received.
- Specified by:
onBodyPartReceived in interface AsyncHandler<T>
- Parameters:
content - response's body part.
- Returns:
- a
AsyncHandler.STATE telling to CONTINUE or ABORT the current processing.
- Throws:
Exception - if something wrong happens
onStatusReceived
public final AsyncHandler.STATE onStatusReceived(HttpResponseStatus status)
throws Exception
- Invoked as soon as the HTTP status line has been received
- Specified by:
onStatusReceived in interface AsyncHandler<T>
- Parameters:
status - the status code and test of the response
- Returns:
- a
AsyncHandler.STATE telling to CONTINUE or ABORT the current processing.
- Throws:
Exception - if something wrong happens
onHeadersReceived
public final AsyncHandler.STATE onHeadersReceived(HttpResponseHeaders headers)
throws Exception
- Invoked as soon as the HTTP headers has been received.
- Specified by:
onHeadersReceived in interface AsyncHandler<T>
- Parameters:
headers - the HTTP headers.
- Returns:
- a
AsyncHandler.STATE telling to CONTINUE or ABORT the current processing.
- Throws:
Exception - if something wrong happens
onCompleted
public final T onCompleted()
throws Exception
- Invoked once the HTTP response has been fully received
- Specified by:
onCompleted in interface AsyncHandler<T>
- Returns:
- T Type of the value that will be returned by the associated
Future
- Throws:
Exception - if something wrong happens
onThrowable
public void onThrowable(Throwable t)
- Invoked when an unexpected exception occurs during the processing of the response
- Specified by:
onThrowable in interface AsyncHandler<T>
- Parameters:
t - a Throwable
onCompleted
public abstract T onCompleted(Response response)
throws Exception
- Invoked once the HTTP response has been fully read.
- Parameters:
response - The Response
- Returns:
- Type of the value that will be returned by the associated
Future
- Throws:
Exception
onHeaderWriteCompleted
public AsyncHandler.STATE onHeaderWriteCompleted()
- Invoked when the content (a
File, String or FileInputStream has been fully
written on the I/O socket.
- Specified by:
onHeaderWriteCompleted in interface ProgressAsyncHandler<T>
- Returns:
- a
AsyncHandler.STATE telling to CONTINUE or ABORT the current processing.
onContentWriteCompleted
public AsyncHandler.STATE onContentWriteCompleted()
- Invoked when the content (a
File, String or FileInputStream has been fully
written on the I/O socket.
- Specified by:
onContentWriteCompleted in interface ProgressAsyncHandler<T>
- Returns:
- a
AsyncHandler.STATE telling to CONTINUE or ABORT the current processing.
onContentWriteProgess
public AsyncHandler.STATE onContentWriteProgess(long amount,
long current,
long total)
- Invoked when the I/O operation associated with the
Request body as been progressed.
- Specified by:
onContentWriteProgess in interface ProgressAsyncHandler<T>
- Parameters:
amount - The amount of bytes to transfer.current - The amount of bytes transferredtotal - The total number of bytes transferred
- Returns:
- a
AsyncHandler.STATE telling to CONTINUE or ABORT the current processing.
Copyright © 2010. All Rights Reserved.