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>
AbstractHttpAsyncResponseConsumer
implementation 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 boolean
cancel()
void
close()
void
consumeContent(ContentDecoder decoder, IOControl ioctrl)
UseonContentReceived(ContentDecoder, IOControl)
instead.void
failed(java.lang.Exception ex)
Invoked to signal that the response processing terminated abnormally.java.lang.Exception
getException()
Returns an exception in case of an abnormal termination.T
getResult()
Returns a result of the response processing, when available.boolean
isDone()
Determines whether or not the response processing completed.void
responseCompleted(HttpContext context)
UsebuildResult(HttpContext)
instead.void
responseReceived(HttpResponse response)
UseonResponseReceived(HttpResponse)
instead.
-
-
-
Method Detail
-
responseReceived
public final void responseReceived(HttpResponse response) throws java.io.IOException, HttpException
UseonResponseReceived(HttpResponse)
instead.- Specified by:
responseReceived
in 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:
consumeContent
in 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:
responseCompleted
in interfaceHttpAsyncResponseConsumer<T>
- Parameters:
context
- HTTP context
-
cancel
public final boolean cancel()
- Specified by:
cancel
in interfaceCancellable
-
failed
public final void failed(java.lang.Exception ex)
Description copied from interface:HttpAsyncResponseConsumer
Invoked to signal that the response processing terminated abnormally.- Specified by:
failed
in interfaceHttpAsyncResponseConsumer<T>
- Parameters:
ex
- exception
-
close
public final void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
getException
public java.lang.Exception getException()
Description copied from interface:HttpAsyncResponseConsumer
Returns an exception in case of an abnormal termination. This method returnsnull
if the response processing is still ongoing or if it completed successfully.- Specified by:
getException
in interfaceHttpAsyncResponseConsumer<T>
- See Also:
HttpAsyncResponseConsumer.isDone()
-
getResult
public T getResult()
Description copied from interface:HttpAsyncResponseConsumer
Returns a result of the response processing, when available. This method returnsnull
if the response processing is still ongoing.- Specified by:
getResult
in interfaceHttpAsyncResponseConsumer<T>
- See Also:
HttpAsyncResponseConsumer.isDone()
-
isDone
public boolean isDone()
Description copied from interface:HttpAsyncResponseConsumer
Determines 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:
isDone
in interfaceHttpAsyncResponseConsumer<T>
-
-