@ThreadSafe public abstract class AbstractAsyncResponseConsumer<T> extends java.lang.Object implements HttpAsyncResponseConsumer<T>
HttpAsyncResponseConsumer implementation that relieves its
subclasses form having to synchronize access to internal instance variables
and provides a number of protected methods that they need to implement.| 构造器和说明 |
|---|
AbstractAsyncResponseConsumer() |
| 限定符和类型 | 方法和说明 |
|---|---|
protected abstract T |
buildResult(HttpContext context)
Invoked to generate a result object from the received HTTP response
message.
|
boolean |
cancel() |
void |
close() |
void |
consumeContent(ContentDecoder decoder,
IOControl ioctrl)
Use
onContentReceived(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.
|
protected void |
onClose()
Invoked when the consumer is being closed.
|
protected abstract void |
onContentReceived(ContentDecoder decoder,
IOControl ioctrl)
Invoked to process a chunk of content from the
ContentDecoder. |
protected abstract void |
onEntityEnclosed(HttpEntity entity,
ContentType contentType)
Invoked if the response message encloses a content entity.
|
protected abstract void |
onResponseReceived(HttpResponse response)
Invoked when a HTTP response message is received.
|
protected abstract void |
releaseResources()
Invoked to release all system resources currently tlb.
|
void |
responseCompleted(HttpContext context)
Use
buildResult(HttpContext) instead. |
void |
responseReceived(HttpResponse response)
Use
onResponseReceived(HttpResponse) instead. |
protected abstract void onResponseReceived(HttpResponse response) throws HttpException, java.io.IOException
onContentReceived(ContentDecoder, IOControl) method
will be invoked only if the response messages has a content entity
enclosed.response - HTTP response message.HttpException - in case of HTTP protocol violationjava.io.IOException - in case of an I/O errorprotected abstract void onContentReceived(ContentDecoder decoder, IOControl ioctrl) throws java.io.IOException
ContentDecoder.
The IOControl interface can be used to suspend input events
if the consumer is temporarily unable to consume more content.
The consumer can use the ContentDecoder.isCompleted() method
to find out whether or not the message content has been fully consumed.decoder - content decoder.ioctrl - I/O control of the underlying connection.java.io.IOException - in case of an I/O errorprotected abstract void onEntityEnclosed(HttpEntity entity, ContentType contentType) throws java.io.IOException
entity - HTTP entitycontentType - expected content category.java.io.IOException - in case of an I/O errorprotected abstract T buildResult(HttpContext context) throws java.lang.Exception
context - HTTP context.java.lang.Exception - in case of an abnormal termination.protected abstract void releaseResources()
protected void onClose()
throws java.io.IOException
java.io.IOException - may be thrown by subclasssespublic final void responseReceived(HttpResponse response) throws java.io.IOException, HttpException
onResponseReceived(HttpResponse) instead.responseReceived 在接口中 HttpAsyncResponseConsumer<T>response - HTTP response message.java.io.IOException - in case of an I/O errorHttpException - in case of HTTP protocol violationpublic final void consumeContent(ContentDecoder decoder, IOControl ioctrl) throws java.io.IOException
onContentReceived(ContentDecoder, IOControl) instead.consumeContent 在接口中 HttpAsyncResponseConsumer<T>decoder - content decoder.ioctrl - I/O control of the underlying connection.java.io.IOException - in case of an I/O errorpublic final void responseCompleted(HttpContext context)
buildResult(HttpContext) instead.responseCompleted 在接口中 HttpAsyncResponseConsumer<T>context - HTTP contextpublic final boolean cancel()
cancel 在接口中 Cancellablepublic final void failed(java.lang.Exception ex)
HttpAsyncResponseConsumerfailed 在接口中 HttpAsyncResponseConsumer<T>ex - exceptionpublic final void close()
throws java.io.IOException
close 在接口中 java.io.Closeableclose 在接口中 java.lang.AutoCloseablejava.io.IOExceptionpublic java.lang.Exception getException()
HttpAsyncResponseConsumernull if the response processing is still ongoing
or if it completed successfully.getException 在接口中 HttpAsyncResponseConsumer<T>HttpAsyncResponseConsumer.isDone()public T getResult()
HttpAsyncResponseConsumernull if the response processing is still ongoing.getResult 在接口中 HttpAsyncResponseConsumer<T>HttpAsyncResponseConsumer.isDone()public boolean isDone()
HttpAsyncResponseConsumerHttpAsyncResponseConsumer.getResult()
can be used to obtain the result. If the response processing terminated
abnormally HttpAsyncResponseConsumer.getException() can be used to obtain the cause.isDone 在接口中 HttpAsyncResponseConsumer<T>