Package org.apache.http.nio.protocol
Class AbstractAsyncResponseConsumer<T>
- java.lang.Object
-
- org.apache.http.nio.protocol.AbstractAsyncResponseConsumer<T>
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,Cancellable,HttpAsyncResponseConsumer<T>
- Direct Known Subclasses:
BasicAsyncResponseConsumer
public abstract class AbstractAsyncResponseConsumer<T> extends java.lang.Object implements HttpAsyncResponseConsumer<T>
AbstractHttpAsyncResponseConsumerimplementation that relieves its subclasses from having to manage internal state and provides a number of protected event methods that they need to implement.- Since:
- 4.2
-
-
Constructor Summary
Constructors Constructor Description AbstractAsyncResponseConsumer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancancel()voidclose()voidconsumeContent(ContentDecoder decoder, IOControl ioctrl)UseonContentReceived(ContentDecoder, IOControl)instead.voidfailed(java.lang.Exception ex)Invoked to signal that the response processing terminated abnormally.java.lang.ExceptiongetException()Returns an exception in case of an abnormal termination.TgetResult()Returns a result of the response processing, when available.booleanisDone()Determines whether or not the response processing completed.voidresponseCompleted(HttpContext context)UsebuildResult(HttpContext)instead.voidresponseReceived(HttpResponse response)UseonResponseReceived(HttpResponse)instead.
-
-
-
Method Detail
-
responseReceived
public final void responseReceived(HttpResponse response) throws java.io.IOException, HttpException
UseonResponseReceived(HttpResponse)instead.- Specified by:
responseReceivedin interfaceHttpAsyncResponseConsumer<T>- Parameters:
response- HTTP response message.- Throws:
java.io.IOException- in case of an I/O errorHttpException- in case of HTTP protocol violation
-
consumeContent
public final void consumeContent(ContentDecoder decoder, IOControl ioctrl) throws java.io.IOException
UseonContentReceived(ContentDecoder, IOControl)instead.- Specified by:
consumeContentin interfaceHttpAsyncResponseConsumer<T>- Parameters:
decoder- content decoder.ioctrl- I/O control of the underlying connection.- Throws:
java.io.IOException- in case of an I/O error
-
responseCompleted
public final void responseCompleted(HttpContext context)
UsebuildResult(HttpContext)instead.- Specified by:
responseCompletedin interfaceHttpAsyncResponseConsumer<T>- Parameters:
context- HTTP context
-
cancel
public final boolean cancel()
- Specified by:
cancelin interfaceCancellable
-
failed
public final void failed(java.lang.Exception ex)
Description copied from interface:HttpAsyncResponseConsumerInvoked to signal that the response processing terminated abnormally.- Specified by:
failedin interfaceHttpAsyncResponseConsumer<T>- Parameters:
ex- exception
-
close
public final void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
getException
public java.lang.Exception getException()
Description copied from interface:HttpAsyncResponseConsumerReturns an exception in case of an abnormal termination. This method returnsnullif the response processing is still ongoing or if it completed successfully.- Specified by:
getExceptionin interfaceHttpAsyncResponseConsumer<T>- See Also:
HttpAsyncResponseConsumer.isDone()
-
getResult
public T getResult()
Description copied from interface:HttpAsyncResponseConsumerReturns a result of the response processing, when available. This method returnsnullif the response processing is still ongoing.- Specified by:
getResultin interfaceHttpAsyncResponseConsumer<T>- See Also:
HttpAsyncResponseConsumer.isDone()
-
isDone
public boolean isDone()
Description copied from interface:HttpAsyncResponseConsumerDetermines whether or not the response processing completed. If the response processing terminated normallyHttpAsyncResponseConsumer.getResult()can be used to obtain the result. If the response processing terminated abnormallyHttpAsyncResponseConsumer.getException()can be used to obtain the cause.- Specified by:
isDonein interfaceHttpAsyncResponseConsumer<T>
-
-