Package org.apache.http.nio.protocol
Class AbstractAsyncRequestConsumer<T>
- java.lang.Object
-
- org.apache.http.nio.protocol.AbstractAsyncRequestConsumer<T>
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,HttpAsyncRequestConsumer<T>
- Direct Known Subclasses:
BasicAsyncRequestConsumer
public abstract class AbstractAsyncRequestConsumer<T> extends java.lang.Object implements HttpAsyncRequestConsumer<T>
AbstractHttpAsyncRequestConsumer
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 AbstractAsyncRequestConsumer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
consumeContent(ContentDecoder decoder, IOControl ioctrl)
UseonContentReceived(ContentDecoder, IOControl)
instead.void
failed(java.lang.Exception ex)
Invoked to signal that the request processing terminated abnormally.java.lang.Exception
getException()
Returns an exception in case of an abnormal termination.T
getResult()
Returns a result of the request execution, when available.boolean
isDone()
Determines whether or not the request execution completed.void
requestCompleted(HttpContext context)
UsebuildResult(HttpContext)
instead.void
requestReceived(HttpRequest request)
UseonRequestReceived(HttpRequest)
instead.
-
-
-
Method Detail
-
requestReceived
public final void requestReceived(HttpRequest request) throws HttpException, java.io.IOException
UseonRequestReceived(HttpRequest)
instead.- Specified by:
requestReceived
in interfaceHttpAsyncRequestConsumer<T>
- Parameters:
request
- HTTP request message.- Throws:
HttpException
- in case of HTTP protocol violationjava.io.IOException
- in case of an I/O error
-
consumeContent
public final void consumeContent(ContentDecoder decoder, IOControl ioctrl) throws java.io.IOException
UseonContentReceived(ContentDecoder, IOControl)
instead.- Specified by:
consumeContent
in interfaceHttpAsyncRequestConsumer<T>
- Parameters:
decoder
- content decoder.ioctrl
- I/O control of the underlying connection.- Throws:
java.io.IOException
- in case of an I/O error
-
requestCompleted
public final void requestCompleted(HttpContext context)
UsebuildResult(HttpContext)
instead.- Specified by:
requestCompleted
in interfaceHttpAsyncRequestConsumer<T>
- Parameters:
context
- HTTP context
-
failed
public final void failed(java.lang.Exception ex)
Description copied from interface:HttpAsyncRequestConsumer
Invoked to signal that the request processing terminated abnormally.- Specified by:
failed
in interfaceHttpAsyncRequestConsumer<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:HttpAsyncRequestConsumer
Returns an exception in case of an abnormal termination. This method returnsnull
if the request execution is still ongoing or if it completed successfully.- Specified by:
getException
in interfaceHttpAsyncRequestConsumer<T>
- See Also:
HttpAsyncRequestConsumer.isDone()
-
getResult
public T getResult()
Description copied from interface:HttpAsyncRequestConsumer
Returns a result of the request execution, when available. This method returnsnull
if the request execution is still ongoing.- Specified by:
getResult
in interfaceHttpAsyncRequestConsumer<T>
- See Also:
HttpAsyncRequestConsumer.isDone()
-
isDone
public boolean isDone()
Description copied from interface:HttpAsyncRequestConsumer
Determines whether or not the request execution completed. If the request processing terminated normallyHttpAsyncRequestConsumer.getResult()
can be used to obtain the result. If the request processing terminated abnormallyHttpAsyncRequestConsumer.getException()
can be used to obtain the cause.- Specified by:
isDone
in interfaceHttpAsyncRequestConsumer<T>
-
-