com.ning.http.client
Class AsyncCompletionHandler<T>

java.lang.Object
  extended by com.ning.http.client.AsyncCompletionHandler<T>
Type Parameters:
T - Type of the value that will be returned by the associated Future
All Implemented Interfaces:
AsyncHandler<T>
Direct Known Subclasses:
AsyncCompletionHandlerBase

public abstract class AsyncCompletionHandler<T>
extends Object
implements AsyncHandler<T>

An AsyncHandler augmented with an onCompleted(Response) convenience method which gets called when the Response has been fully received.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.ning.http.client.AsyncHandler
AsyncHandler.STATE
 
Constructor Summary
AsyncCompletionHandler()
           
 
Method Summary
 AsyncHandler.STATE onBodyPartReceived(HttpResponseBodyPart content)
          Invoked as soon as some response body part are received.
 T onCompleted()
          Invoked once the HTTP response has been fully received
abstract  T onCompleted(Response response)
          Invoked once the HTTP response has been fully read.
 AsyncHandler.STATE onHeadersReceived(HttpResponseHeaders headers)
          Invoked as soon as the HTTP headers has been received.
 AsyncHandler.STATE onStatusReceived(HttpResponseStatus status)
          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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AsyncCompletionHandler

public AsyncCompletionHandler()
Method Detail

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.
Throws:
Exception

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
Throws:
Exception

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.
Throws:
Exception

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

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


Copyright © 2010. All Rights Reserved.