com.ning.http.client
Interface AsyncHandler<T>

Type Parameters:
T - Type of object returned by the Future.get()
All Known Implementing Classes:
AsyncCompletionHandler, AsyncCompletionHandlerBase

public interface AsyncHandler<T>

An asynchronous handler or callback which gets invoked as soon as some data are available when processing an asynchronous response. Callbacks method gets invoked in the following order: (1) onStatusReceived(HttpResponseStatus) (2) onHeadersReceived(HttpResponseHeaders) (3) onBodyPartReceived(HttpResponseBodyPart), which could be invoked multiple times (4) onCompleted(), once the response has been fully read. Interrupting the process of the asynchronous response can be achieved by returning a AsyncHandler.STATE.ABORT at any moment during the processing of the asynchronous response.


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 has been fully received
 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

onThrowable

void onThrowable(Throwable t)
Invoked when an unexpected exception occurs during the processing of the response

Parameters:
t - a Throwable

onBodyPartReceived

AsyncHandler.STATE onBodyPartReceived(HttpResponseBodyPart bodyPart)
                                      throws Exception
Invoked as soon as some response body part are received.

Parameters:
bodyPart - response's body part.
Throws:
Exception

onStatusReceived

AsyncHandler.STATE onStatusReceived(HttpResponseStatus responseStatus)
                                    throws Exception
Invoked as soon as the HTTP status line has been received

Parameters:
responseStatus - the status code and test of the response
Throws:
Exception

onHeadersReceived

AsyncHandler.STATE onHeadersReceived(HttpResponseHeaders headers)
                                     throws Exception
Invoked as soon as the HTTP headers has been received.

Parameters:
headers - the HTTP headers.
Throws:
Exception

onCompleted

T onCompleted()
              throws Exception
Invoked once the HTTP response has been fully received

Returns:
T Type of the value that will be returned by the associated Future
Throws:
Exception


Copyright © 2010. All Rights Reserved.