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
AsyncClientExchangeHandler
produceRequest
in interface AsyncClientExchangeHandler
requestChannel
- the request channel capable to accepting a request message.httpContext
- the actual execution context.HttpException
IOException
public int available()
AsyncDataProducer
available
in interface AsyncDataProducer
public void produce(DataStreamChannel channel) throws IOException
AsyncDataProducer
produce
in interface AsyncDataProducer
channel
- the data channel capable to accepting more data.IOException
public void consumeInformation(HttpResponse response, HttpContext httpContext) throws HttpException, IOException
AsyncClientExchangeHandler
consumeInformation
in interface AsyncClientExchangeHandler
response
- the intermediate (1xx) HTTP response.httpContext
- the actual execution context.HttpException
IOException
public void consumeResponse(HttpResponse response, EntityDetails entityDetails, HttpContext httpContext) throws HttpException, IOException
AsyncClientExchangeHandler
consumeResponse
in interface AsyncClientExchangeHandler
response
- 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
IOException
public void cancel()
AsyncClientExchangeHandler
cancel
in interface AsyncClientExchangeHandler
public void updateCapacity(CapacityChannel capacityChannel) throws IOException
AsyncDataConsumer
updateCapacity
in interface AsyncDataConsumer
capacityChannel
- the channel for capacity updates.IOException
public void consume(ByteBuffer src) throws IOException
AsyncDataConsumer
consume
in interface AsyncDataConsumer
src
- data source.IOException
public void streamEnd(List<? extends Header> trailers) throws HttpException, IOException
AsyncDataConsumer
streamEnd
in interface AsyncDataConsumer
trailers
- data stream trailers.HttpException
IOException
public void failed(Exception cause)
AsyncDataExchangeHandler
failed
in interface AsyncDataExchangeHandler
cause
- the cause of the failure.public void releaseResources()
releaseResources
in interface ResourceHolder
Copyright © 2005–2021 The Apache Software Foundation. All rights reserved.