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

public abstract Class AbstractAsyncRequesterConsumer<T, E>

extends Object
implements AsyncRequestConsumer<T>
Class Inheritance
All Implemented Interfaces
org.apache.hc.core5.http.nio.AsyncRequestConsumer, org.apache.hc.core5.http.nio.AsyncDataConsumer, org.apache.hc.core5.http.nio.ResourceHolder
Type Parameters
<T>
request processing result representation.
<E>
request entity representation.
Imports
java.io.IOException, java.nio.ByteBuffer, java.nio.charset.UnsupportedCharsetException, java.util.List, java.util.concurrent.atomic.AtomicReference, org.apache.hc.core5.concurrent.CallbackContribution, .FutureCallback, org.apache.hc.core5.function.Supplier, org.apache.hc.core5.http.ContentType, .EntityDetails, .Header, .HttpException, .HttpRequest, org.apache.hc.core5.http.nio.AsyncEntityConsumer, .AsyncRequestConsumer, .CapacityChannel, org.apache.hc.core5.http.protocol.HttpContext, org.apache.hc.core5.util.Args

Abstract asynchronous request consumer that makes use of AsyncEntityConsumer to process request message content.
Since
5.0

Field Summary

Modifier and TypeField and Description
private final AtomicReference<AsyncEntityConsumer<E>>
private final Supplier<AsyncEntityConsumer<E>>

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
protected abstract T

Returns:

the result of request processing.
buildResult
(HttpRequest
the request message.
request
,
E
the request entity.
entity
,
ContentType
the request content type.
contentType
)

Triggered to generate object that represents a result of request message processing.

public final 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 final void
consumeRequest(final HttpRequest
the request message head.
request
,
final EntityDetails
the request entity details or null if the request does not enclose an entity.
entityDetails
,
final HttpContext
the actual execution context.
httpContext
,
final FutureCallback<T>
the result callback called when request processing has been completed successfully or unsuccessfully.
resultCallback
)

Implements org.apache.hc.core5.http.nio.AsyncRequestConsumer.consumeRequest.

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

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

Triggered to signal a failure in data processing.
public final void
public final 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 final 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

dataConsumerRefback to summary
private final AtomicReference<AsyncEntityConsumer<E>> dataConsumerRef
dataConsumerSupplierback to summary
private final Supplier<AsyncEntityConsumer<E>> dataConsumerSupplier

Constructor Detail

AbstractAsyncRequesterConsumerback to summary
public AbstractAsyncRequesterConsumer(final Supplier<AsyncEntityConsumer<E>> dataConsumerSupplier)
AbstractAsyncRequesterConsumerback to summary
public AbstractAsyncRequesterConsumer(final AsyncEntityConsumer<E> dataConsumer)

Method Detail

buildResultback to summary
protected abstract T buildResult(HttpRequest request, E entity, ContentType contentType)

Triggered to generate object that represents a result of request message processing.

Parameters
request:HttpRequest

the request message.

entity:E

the request entity.

contentType:ContentType

the request content type.

Returns:T

the result of request processing.

consumeback to summary
public final 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
consumeRequestback to summary
public final void consumeRequest(final HttpRequest request, final EntityDetails entityDetails, final HttpContext httpContext, final FutureCallback<T> resultCallback) throws HttpException, IOException

Implements org.apache.hc.core5.http.nio.AsyncRequestConsumer.consumeRequest.

Doc from org.apache.hc.core5.http.nio.AsyncRequestConsumer.consumeRequest.

Triggered to signal receipt of a request message head.

Parameters
request:HttpRequest

the request message head.

entityDetails:EntityDetails

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

httpContext:HttpContext

the actual execution context.

resultCallback:FutureCallback<T>

the result callback called when request processing has been completed successfully or unsuccessfully.

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

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

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

Triggered to signal a failure in data processing.

Parameters
cause:Exception

the cause of the failure.

Annotations
@Override
releaseResourcesback to summary
public final void releaseResources()

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

Annotations
@Override
streamEndback to summary
public final 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 final 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