|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.http.nio.protocol.AbstractAsyncResponseConsumer<T>
public abstract class AbstractAsyncResponseConsumer<T>
Abstract HttpAsyncResponseConsumer implementation that relieves its
subclasses from having to manage internal state and provides a number of protected
event methods that they need to implement.
| Constructor Summary | |
|---|---|
AbstractAsyncResponseConsumer()
|
|
| Method Summary | |
|---|---|
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(Exception ex)
Invoked to signal that the response processing terminated abnormally. |
protected ContentType |
getContentType(HttpEntity entity)
|
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 allocated. |
void |
responseCompleted(HttpContext context)
Use buildResult(HttpContext) instead. |
void |
responseReceived(HttpResponse response)
Use onResponseReceived(HttpResponse) instead. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AbstractAsyncResponseConsumer()
| Method Detail |
|---|
protected abstract void onResponseReceived(HttpResponse response)
throws HttpException,
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 violation
IOException - in case of an I/O error
protected abstract void onContentReceived(ContentDecoder decoder,
IOControl ioctrl)
throws 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.
IOException - in case of an I/O error
protected abstract void onEntityEnclosed(HttpEntity entity,
ContentType contentType)
throws IOException
entity - HTTP entitycontentType - expected content type.
IOException - in case of an I/O error
protected abstract T buildResult(HttpContext context)
throws Exception
context - HTTP context.
Exception - in case of an abnormal termination.protected abstract void releaseResources()
protected void onClose()
throws IOException
IOException - may be thrown by subclasssesprotected ContentType getContentType(HttpEntity entity)
public final void responseReceived(HttpResponse response)
throws IOException,
HttpException
onResponseReceived(HttpResponse) instead.
responseReceived in interface HttpAsyncResponseConsumer<T>response - HTTP response message.
IOException - in case of an I/O error
HttpException - in case of HTTP protocol violation
public final void consumeContent(ContentDecoder decoder,
IOControl ioctrl)
throws IOException
onContentReceived(ContentDecoder, IOControl) instead.
consumeContent in interface HttpAsyncResponseConsumer<T>decoder - content decoder.ioctrl - I/O control of the underlying connection.
IOException - in case of an I/O errorpublic final void responseCompleted(HttpContext context)
buildResult(HttpContext) instead.
responseCompleted in interface HttpAsyncResponseConsumer<T>context - HTTP contextpublic final boolean cancel()
cancel in interface Cancellablepublic final void failed(Exception ex)
HttpAsyncResponseConsumer
failed in interface HttpAsyncResponseConsumer<T>ex - exception
public final void close()
throws IOException
close in interface CloseableIOExceptionpublic Exception getException()
HttpAsyncResponseConsumernull if the response processing is still ongoing
or if it completed successfully.
getException in interface HttpAsyncResponseConsumer<T>HttpAsyncResponseConsumer.isDone()public T getResult()
HttpAsyncResponseConsumernull if the response processing is still ongoing.
getResult in interface 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 in interface HttpAsyncResponseConsumer<T>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||