Top Description Fields Constructors Methods
org.apache.hc.core5.http.nio.support

public final Class BasicClientExchangeHandler<T>

extends Object
implements AsyncClientExchangeHandler
Class Inheritance
All Implemented Interfaces
org.apache.hc.core5.http.nio.AsyncClientExchangeHandler, org.apache.hc.core5.http.nio.AsyncDataExchangeHandler, org.apache.hc.core5.http.nio.AsyncDataProducer, org.apache.hc.core5.http.nio.ResourceHolder, org.apache.hc.core5.http.nio.AsyncDataConsumer
Imports
java.io.IOException, java.nio.ByteBuffer, java.util.List, java.util.concurrent.atomic.AtomicBoolean, org.apache.hc.core5.concurrent.FutureCallback, org.apache.hc.core5.http.EntityDetails, .Header, .HttpException, .HttpResponse, .HttpStatus, org.apache.hc.core5.http.nio.AsyncClientExchangeHandler, .AsyncRequestProducer, .AsyncResponseConsumer, .CapacityChannel, .DataStreamChannel, .RequestChannel, org.apache.hc.core5.http.protocol.HttpContext, org.apache.hc.core5.util.Args

Basic AsyncClientExchangeHandler implementation that makes use of AsyncRequestProducer to generate request message and AsyncResponseConsumer to process the response message returned by the server.
Since
5.0

Field Summary

Modifier and TypeField and Description
private final AtomicBoolean
private final AtomicBoolean
private final AsyncRequestProducer
private final AsyncResponseConsumer<T>
private final FutureCallback<T>

Constructor Summary

AccessConstructor and Description
public
BasicClientExchangeHandler(final AsyncRequestProducer requestProducer, final AsyncResponseConsumer<T> responseConsumer, final FutureCallback<T> resultCallback)

Method Summary

Modifier and TypeMethod and Description
public int
available()

Implements org.apache.hc.core5.http.nio.AsyncDataProducer.available.

Returns the number of bytes immediately available for output.
public void
cancel()

Implements org.apache.hc.core5.http.nio.AsyncClientExchangeHandler.cancel.

Triggered to cancel the message exchange.
public void
consume(final ByteBuffer
data source.
src
)

Implements org.apache.hc.core5.http.nio.AsyncDataConsumer.consume.

Triggered to pass incoming data to the data consumer.
public void
consumeInformation(final HttpResponse
the intermediate (1xx) HTTP response.
response
,
final HttpContext
the actual execution context.
httpContext
)

Implements org.apache.hc.core5.http.nio.AsyncClientExchangeHandler.consumeInformation.

Triggered to signal receipt of an intermediate (1xx) HTTP response.
public void
consumeResponse(final HttpResponse
the response message head.
response
,
final EntityDetails
the response entity details or null if the response does not enclose an entity.
entityDetails
,
final HttpContext
the actual execution context.
httpContext
)

Implements org.apache.hc.core5.http.nio.AsyncClientExchangeHandler.consumeResponse.

Triggered to signal receipt of a response message head.
public void
failed(final Exception
the cause of the failure.
cause
)

Implements org.apache.hc.core5.http.nio.AsyncDataExchangeHandler.failed.

Triggered to signal a failure in data processing.
private void
public void
produce(final DataStreamChannel
the data channel capable to accepting more data.
channel
)

Implements org.apache.hc.core5.http.nio.AsyncDataProducer.produce.

Triggered to signal the ability of the underlying data channel to accept more data.
public void
produceRequest(final RequestChannel
the request channel capable to accepting a request message.
requestChannel
,
final HttpContext
the actual execution context.
httpContext
)

Implements org.apache.hc.core5.http.nio.AsyncClientExchangeHandler.produceRequest.

Triggered to signal the ability of the underlying request channel to accept a request messages.
public void
public void
streamEnd(final List<? extends Header>
data stream trailers.
trailers
)

Implements org.apache.hc.core5.http.nio.AsyncDataConsumer.streamEnd.

Triggered to signal termination of the data stream.
public void
updateCapacity(final CapacityChannel
the channel for capacity updates.
capacityChannel
)

Implements org.apache.hc.core5.http.nio.AsyncDataConsumer.updateCapacity.

Triggered to signal ability of the underlying data stream to receive data capacity update.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

completedback to summary
private final AtomicBoolean completed
outputTerminatedback to summary
private final AtomicBoolean outputTerminated
requestProducerback to summary
private final AsyncRequestProducer requestProducer
responseConsumerback to summary
private final AsyncResponseConsumer<T> responseConsumer
resultCallbackback to summary
private final FutureCallback<T> resultCallback

Constructor Detail

BasicClientExchangeHandlerback to summary
public BasicClientExchangeHandler(final AsyncRequestProducer requestProducer, final AsyncResponseConsumer<T> responseConsumer, final FutureCallback<T> resultCallback)

Method Detail

availableback to summary
public int available()

Implements org.apache.hc.core5.http.nio.AsyncDataProducer.available.

Doc from org.apache.hc.core5.http.nio.AsyncDataProducer.available.

Returns the number of bytes immediately available for output. This method can be used as a hint to control output events of the underlying I/O session.

Returns:int

the number of bytes immediately available for output

Annotations
@Override
cancelback to summary
public void cancel()

Implements org.apache.hc.core5.http.nio.AsyncClientExchangeHandler.cancel.

Doc from org.apache.hc.core5.http.nio.AsyncClientExchangeHandler.cancel.

Triggered to cancel the message exchange.

Annotations
@Override
consumeback to summary
public void consume(final ByteBuffer src) throws IOException

Implements org.apache.hc.core5.http.nio.AsyncDataConsumer.consume.

Doc from org.apache.hc.core5.http.nio.AsyncDataConsumer.consume.

Triggered to pass incoming data to the data consumer. The consumer must consume the entire content of the data buffer. The consumer must stop incrementing its capacity on the capacity channel if it is unable to accept more data. Once the data consumer has handled accumulated data or allocated more intermediate storage it can update its capacity information on the capacity channel.

Parameters
src:ByteBuffer

data source.

Annotations
@Override
consumeInformationback to summary
public void consumeInformation(final HttpResponse response, final HttpContext httpContext) throws HttpException, IOException

Implements org.apache.hc.core5.http.nio.AsyncClientExchangeHandler.consumeInformation.

Doc from org.apache.hc.core5.http.nio.AsyncClientExchangeHandler.consumeInformation.

Triggered to signal receipt of an intermediate (1xx) HTTP response.

Parameters
response:HttpResponse

the intermediate (1xx) HTTP response.

httpContext:HttpContext

the actual execution context.

Annotations
@Override
consumeResponseback to summary
public void consumeResponse(final HttpResponse response, final EntityDetails entityDetails, final HttpContext httpContext) throws HttpException, IOException

Implements org.apache.hc.core5.http.nio.AsyncClientExchangeHandler.consumeResponse.

Doc from org.apache.hc.core5.http.nio.AsyncClientExchangeHandler.consumeResponse.

Triggered to signal receipt of a response message head.

Parameters
response:HttpResponse

the response message head.

entityDetails:EntityDetails

the response entity details or null if the response does not enclose an entity.

httpContext:HttpContext

the actual execution context.

Annotations
@Override
failedback to summary
public void failed(final Exception cause)

Implements org.apache.hc.core5.http.nio.AsyncDataExchangeHandler.failed.

Doc from org.apache.hc.core5.http.nio.AsyncDataExchangeHandler.failed.

Triggered to signal a failure in data processing.

Parameters
cause:Exception

the cause of the failure.

Annotations
@Override
internalReleaseResourcesback to summary
private void internalReleaseResources()
produceback to summary
public void produce(final DataStreamChannel channel) throws IOException

Implements org.apache.hc.core5.http.nio.AsyncDataProducer.produce.

Doc from org.apache.hc.core5.http.nio.AsyncDataProducer.produce.

Triggered to signal the ability of the underlying data channel to accept more data. The data producer can choose to write data immediately inside the call or asynchronously at some later point.

Parameters
channel:DataStreamChannel

the data channel capable to accepting more data.

Annotations
@Override
produceRequestback to summary
public void produceRequest(final RequestChannel requestChannel, final HttpContext httpContext) throws HttpException, IOException

Implements org.apache.hc.core5.http.nio.AsyncClientExchangeHandler.produceRequest.

Doc from org.apache.hc.core5.http.nio.AsyncClientExchangeHandler.produceRequest.

Triggered to signal the ability of the underlying request channel to accept a request messages. The data producer can choose to send a request message immediately inside the call or asynchronously at some later point.

Parameters
requestChannel:RequestChannel

the request channel capable to accepting a request message.

httpContext:HttpContext

the actual execution context.

Annotations
@Override
releaseResourcesback to summary
public void releaseResources()

Implements org.apache.hc.core5.http.nio.ResourceHolder.releaseResources.

Annotations
@Override
streamEndback to summary
public void streamEnd(final List<? extends Header> trailers) throws HttpException, IOException

Implements org.apache.hc.core5.http.nio.AsyncDataConsumer.streamEnd.

Doc from org.apache.hc.core5.http.nio.AsyncDataConsumer.streamEnd.

Triggered to signal termination of the data stream.

Parameters
trailers:List<? extends Header>

data stream trailers.

Annotations
@Override
updateCapacityback to summary
public void updateCapacity(final CapacityChannel capacityChannel) throws IOException

Implements org.apache.hc.core5.http.nio.AsyncDataConsumer.updateCapacity.

Doc from org.apache.hc.core5.http.nio.AsyncDataConsumer.updateCapacity.

Triggered to signal ability of the underlying data stream to receive data capacity update. The data consumer can choose to write data immediately inside the call or asynchronously at some later point.

Parameters
capacityChannel:CapacityChannel

the channel for capacity updates.

Annotations
@Override