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

public abstract Class AbstractClassicServerExchangeHandler

extends Object
implements AsyncServerExchangeHandler
Class Inheritance
All Implemented Interfaces
org.apache.hc.core5.http.nio.AsyncServerExchangeHandler, 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, .InputStream, .OutputStream, java.nio.ByteBuffer, java.util.List, .Locale, .Set, java.util.concurrent.Executor, java.util.concurrent.atomic.AtomicBoolean, .AtomicReference, org.apache.hc.core5.http.EntityDetails, .Header, .HttpException, .HttpHeaders, .HttpRequest, .HttpResponse, .HttpStatus, .ProtocolVersion, org.apache.hc.core5.http.message.BasicHttpResponse, .HttpResponseWrapper, org.apache.hc.core5.http.nio.AsyncServerExchangeHandler, .CapacityChannel, .DataStreamChannel, .ResponseChannel, org.apache.hc.core5.http.protocol.HttpContext, org.apache.hc.core5.io.Closer, org.apache.hc.core5.util.Args, .Asserts

AsyncServerExchangeHandler implementation that acts as a compatibility layer for classic InputStream / OutputStream based interfaces. Blocking input / output processing is executed through an Executor.
Since
5.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum

Field Summary

Modifier and TypeField and Description
private final AtomicReference<Exception>
private final Executor
private final int
private volatile SharedInputBuffer
private volatile SharedOutputBuffer
private final AtomicReference<AbstractClassicServerExchangeHandler.State>

Constructor Summary

AccessConstructor and Description
public
AbstractClassicServerExchangeHandler(final int initialBufferSize, final Executor executor)

Method Summary

Modifier and TypeMethod and Description
public final int
available()

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

Returns the number of bytes immediately available for output.
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
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.
public Exception
protected abstract void
handle(HttpRequest
the incoming request
request
,
InputStream
the request stream if the request encloses an entity, null otherwise.
requestStream
,
HttpResponse
the outgoing response.
response
,
OutputStream
the response entity output stream.
responseStream
,
HttpContext
the actual execution context.
context
)

Handles an incoming request optionally reading its entity content form the given input stream and generates a response optionally writing out its entity content into the given output stream.

public final void
handleRequest(final HttpRequest
the actual request.
request
,
final EntityDetails
the request entity details or null if the request does not enclose an entity.
entityDetails
,
final ResponseChannel
the response channel.
responseChannel
,
final HttpContext
the actual execution context.
context
)

Implements org.apache.hc.core5.http.nio.AsyncServerExchangeHandler.handleRequest.

Processes the actual HTTP request.
public final 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
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

exceptionback to summary
private final AtomicReference<Exception> exception
executorback to summary
private final Executor executor
initialBufferSizeback to summary
private final int initialBufferSize
inputBufferback to summary
private volatile SharedInputBuffer inputBuffer
outputBufferback to summary
private volatile SharedOutputBuffer outputBuffer
stateback to summary
private final AtomicReference<AbstractClassicServerExchangeHandler.State> state

Constructor Detail

AbstractClassicServerExchangeHandlerback to summary
public AbstractClassicServerExchangeHandler(final int initialBufferSize, final Executor executor)

Method Detail

availableback to summary
public final 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
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
failedback to summary
public final 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
getExceptionback to summary
public Exception getException()
handleback to summary
protected abstract void handle(HttpRequest request, InputStream requestStream, HttpResponse response, OutputStream responseStream, HttpContext context) throws IOException, HttpException

Handles an incoming request optionally reading its entity content form the given input stream and generates a response optionally writing out its entity content into the given output stream.

Parameters
request:HttpRequest

the incoming request

requestStream:InputStream

the request stream if the request encloses an entity, null otherwise.

response:HttpResponse

the outgoing response.

responseStream:OutputStream

the response entity output stream.

context:HttpContext

the actual execution context.

handleRequestback to summary
public final void handleRequest(final HttpRequest request, final EntityDetails entityDetails, final ResponseChannel responseChannel, final HttpContext context) throws HttpException, IOException

Implements org.apache.hc.core5.http.nio.AsyncServerExchangeHandler.handleRequest.

Doc from org.apache.hc.core5.http.nio.AsyncServerExchangeHandler.handleRequest.

Processes the actual HTTP request. The handler can choose to send response messages immediately inside the call or asynchronously at some later point.

Parameters
request:HttpRequest

the actual request.

entityDetails:EntityDetails

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

responseChannel:ResponseChannel

the response channel.

context:HttpContext

the actual execution context.

Annotations
@Override
produceback to summary
public final 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
releaseResourcesback to summary
public 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
org.apache.hc.core5.http.nio.support.classic back to summary

private final Enum AbstractClassicServerExchangeHandler.State

extends Enum<AbstractClassicServerExchangeHandler.State>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final AbstractClassicServerExchangeHandler.State
public static final AbstractClassicServerExchangeHandler.State
public static final AbstractClassicServerExchangeHandler.State

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static AbstractClassicServerExchangeHandler.State
public static AbstractClassicServerExchangeHandler.State[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ACTIVEback to summary
public static final AbstractClassicServerExchangeHandler.State ACTIVE
COMPLETEDback to summary
public static final AbstractClassicServerExchangeHandler.State COMPLETED
IDLEback to summary
public static final AbstractClassicServerExchangeHandler.State IDLE

Constructor Detail

Stateback to summary
private State()

Method Detail

valueOfback to summary
public static AbstractClassicServerExchangeHandler.State valueOf(String name)
valuesback to summary
public static AbstractClassicServerExchangeHandler.State[] values()