T - The result type.public final class BasicClientExchangeHandler<T> extends Object implements AsyncClientExchangeHandler
AsyncClientExchangeHandler implementation that makes use
of AsyncRequestProducer to generate request message
and AsyncResponseConsumer to process the response message returned by the server.| Constructor and Description |
|---|
BasicClientExchangeHandler(AsyncRequestProducer requestProducer,
AsyncResponseConsumer<T> responseConsumer,
FutureCallback<T> resultCallback) |
| Modifier and Type | Method and Description |
|---|---|
int |
available()
Returns the number of bytes immediately available for output.
|
void |
cancel()
Triggered to cancel the message exchange.
|
void |
consume(ByteBuffer src)
Triggered to pass incoming data to the data consumer.
|
void |
consumeInformation(HttpResponse response,
HttpContext httpContext)
Triggered to signal receipt of an intermediate (1xx) HTTP response.
|
void |
consumeResponse(HttpResponse response,
EntityDetails entityDetails,
HttpContext httpContext)
Triggered to signal receipt of a response message head.
|
void |
failed(Exception cause)
Triggered to signal a failure in data processing.
|
void |
produce(DataStreamChannel channel)
Triggered to signal the ability of the underlying data channel
to accept more data.
|
void |
produceRequest(RequestChannel requestChannel,
HttpContext httpContext)
Triggered to signal the ability of the underlying request channel
to accept a request messages.
|
void |
releaseResources() |
void |
streamEnd(List<? extends Header> trailers)
Triggered to signal termination of the data stream.
|
void |
updateCapacity(CapacityChannel capacityChannel)
Triggered to signal ability of the underlying data stream to receive
data capacity update.
|
public BasicClientExchangeHandler(AsyncRequestProducer requestProducer, AsyncResponseConsumer<T> responseConsumer, FutureCallback<T> resultCallback)
public void produceRequest(RequestChannel requestChannel, HttpContext httpContext) throws HttpException, IOException
AsyncClientExchangeHandlerproduceRequest in interface AsyncClientExchangeHandlerrequestChannel - the request channel capable to accepting a request message.httpContext - the actual execution context.HttpException - in case of an HTTP protocol violation.IOException - in case of an I/O error.public int available()
AsyncDataProducer
Please note this method should return zero if the data producer
is unable to produce any more data, in which case
AsyncDataProducer.produce(DataStreamChannel) method will not get triggered.
The producer can resume writing out data asynchronously
once more data becomes available or request output readiness events
with DataStreamChannel.requestOutput().
available in interface AsyncDataProducerAsyncDataProducer.produce(DataStreamChannel),
DataStreamChannel.requestOutput()public void produce(DataStreamChannel channel) throws IOException
AsyncDataProducer
Please note this method gets triggered only if AsyncDataProducer.available()
returns a positive value.
produce in interface AsyncDataProducerchannel - the data channel capable of accepting more data.IOException - in case of an I/O error.AsyncDataProducer.available()public void consumeInformation(HttpResponse response, HttpContext httpContext) throws HttpException, IOException
AsyncClientExchangeHandlerconsumeInformation in interface AsyncClientExchangeHandlerresponse - the intermediate (1xx) HTTP response.httpContext - the actual execution context.HttpException - in case of an HTTP protocol violation.IOException - in case of an I/O error.public void consumeResponse(HttpResponse response, EntityDetails entityDetails, HttpContext httpContext) throws HttpException, IOException
AsyncClientExchangeHandlerconsumeResponse in interface AsyncClientExchangeHandlerresponse - the response message head.entityDetails - the response entity details or null if the response
does not enclose an entity.httpContext - the actual execution context.HttpException - in case of an HTTP protocol violation.IOException - in case of an I/O error.public void cancel()
AsyncClientExchangeHandlercancel in interface AsyncClientExchangeHandlerpublic void updateCapacity(CapacityChannel capacityChannel) throws IOException
AsyncDataConsumerupdateCapacity in interface AsyncDataConsumercapacityChannel - the channel for capacity updates.IOException - in case of an I/O error.public void consume(ByteBuffer src) throws IOException
AsyncDataConsumerconsume in interface AsyncDataConsumersrc - data source.IOException - in case of an I/O error.public void streamEnd(List<? extends Header> trailers) throws HttpException, IOException
AsyncDataConsumerstreamEnd in interface AsyncDataConsumertrailers - data stream trailers.HttpException - in case of an HTTP protocol violation.IOException - in case of an I/O error.public void failed(Exception cause)
AsyncDataExchangeHandlerfailed in interface AsyncDataExchangeHandlercause - the cause of the failure.public void releaseResources()
releaseResources in interface ResourceHolderCopyright © 2005–2021 The Apache Software Foundation. All rights reserved.