Top Description Inners Fields Constructors Methods
io.undertow.server.protocol.ajp

pack-priv final Class AjpServerResponseConduit

extends AbstractFramedStreamSinkConduit
Class Inheritance
Imports
io.undertow.UndertowMessages, .UndertowOptions, io.undertow.conduits.AbstractFramedStreamSinkConduit, .ConduitListener, io.undertow.server.Connectors, .HttpServerExchange, io.undertow.util.HeaderMap, .Headers, .HttpString, .StatusCodes, org.jboss.logging.Logger, org.xnio.Buffers, .IoUtils, io.undertow.connector.ByteBufferPool, .PooledByteBuffer, org.xnio.channels.StreamSourceChannel, org.xnio.conduits.ConduitWritableByteChannel, .StreamSinkConduit, .WriteReadyHandler, java.io.IOException, java.nio.ByteBuffer, java.nio.channels.ClosedChannelException, .FileChannel, java.util.ArrayList, .Collections, .HashMap, .List, .Map

AJP response channel. For now we are going to assume that the buffers are sized to fit complete packets. As AJP packets are limited to 8k this is a reasonable assumption.
Authors
David M. Lloyd, Stuart Douglas

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private static final ByteBuffer
private static final ByteBuffer
private static final int
private final HttpServerExchange
private final ConduitListener<? super AjpServerResponseConduit>
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final ByteBuffer
private static final Map<HttpString, Integer>
private final boolean
private static final Logger
private final ByteBufferPool
private int

Constructor Summary

AccessConstructor and Description
pack-priv
AjpServerResponseConduit(final StreamSinkConduit next, final ByteBufferPool pool, final HttpServerExchange exchange, ConduitListener<? super AjpServerResponseConduit> finishListener, boolean headRequest)

Method Summary

Modifier and TypeMethod and Description
private ByteBuffer[]
pack-priv boolean
protected void
protected void
public boolean
flush()

Overrides org.xnio.conduits.AbstractSinkConduit.flush.

Implements org.xnio.conduits.SinkConduit.flush.

Flush out any unwritten, buffered output.

public boolean
isWriteResumed()

Overrides org.xnio.conduits.AbstractSinkConduit.isWriteResumed.

Implements org.xnio.conduits.SinkConduit.isWriteResumed.

Determine whether write notifications are currently enabled.

public boolean
isWriteShutdown()

Overrides org.xnio.conduits.AbstractSinkConduit.isWriteShutdown.

Implements org.xnio.conduits.SinkConduit.isWriteShutdown.

Determine whether writes have been fully shut down on this conduit.

private void
processAJPHeader()

Handles generating the header if required, and adding it to the frame queue.

private void
private static void
putInt(final ByteBuffer buf, int value)

private static void
putString(final ByteBuffer buf, String value)

protected void
private void
queueRemainingBytes(final ByteBuffer src, final ByteBuffer[] buffers)

public void
resumeWrites()

Overrides org.xnio.conduits.AbstractSinkConduit.resumeWrites.

Implements org.xnio.conduits.SinkConduit.resumeWrites.

Indicate that the conduit's WriteReadyHandler should be invoked as soon as data can be written without blocking.

public void
setWriteReadyHandler(WriteReadyHandler
the filter to receive readiness notifications
handler
)

Overrides org.xnio.conduits.AbstractSinkConduit.setWriteReadyHandler.

Implements org.xnio.conduits.SinkConduit.setWriteReadyHandler.

Set the handler which should receive readiness notifications.

public void
suspendWrites()

Overrides org.xnio.conduits.AbstractSinkConduit.suspendWrites.

Implements org.xnio.conduits.SinkConduit.suspendWrites.

Indicate that calling the conduit's WriteReadyHandler should be suspended.

public long
transferFrom(final FileChannel
the file to read from
src
,
final long
the position within the file from which the transfer is to begin
position
,
final long
the number of bytes to be transferred
count
)

Overrides io.undertow.conduits.AbstractFramedStreamSinkConduit.transferFrom.

Implements org.xnio.conduits.StreamSinkConduit.transferFrom.

Transfer bytes into this conduit from the given file.

public long
transferFrom(final StreamSourceChannel
the source to read from
source
,
final long
the number of bytes to be transferred
count
,
final ByteBuffer
the buffer to copy through.
throughBuffer
)

Overrides io.undertow.conduits.AbstractFramedStreamSinkConduit.transferFrom.

Implements org.xnio.conduits.StreamSinkConduit.transferFrom.

Transfers bytes from the given channel source.

public void
wakeupWrites()

Overrides org.xnio.conduits.AbstractSinkConduit.wakeupWrites.

Implements org.xnio.conduits.SinkConduit.wakeupWrites.

Indicate that the conduit's WriteReadyHandler should be invoked immediately, and then again as soon as data can be written without blocking.

public int
write(final ByteBuffer
the buffer containing data to write
src
)

Overrides io.undertow.conduits.AbstractFramedStreamSinkConduit.write.

Implements org.xnio.conduits.StreamSinkConduit.write.

Writes a sequence of bytes to this conduit from the given buffer.

public long
write(final ByteBuffer[] srcs)

public long
write(final ByteBuffer[]
the buffers containing data to write
srcs
,
final int
the offset into the buffer array
offset
,
final int
the number of buffers to write
length
)

Overrides io.undertow.conduits.AbstractFramedStreamSinkConduit.write.

Implements org.xnio.conduits.StreamSinkConduit.write.

Writes a sequence of bytes to this conduit from the given buffers.

Inherited from io.undertow.conduits.AbstractFramedStreamSinkConduit:
flushQueuedDataisWritesTerminatedqueuedDataLengthqueueFrameterminateWritestruncateWriteswriteFinalwriteFinal

Field Detail

CLOSE_FRAME_NON_PERSISTENTback to summary
private static final ByteBuffer CLOSE_FRAME_NON_PERSISTENT
CLOSE_FRAME_PERSISTENTback to summary
private static final ByteBuffer CLOSE_FRAME_PERSISTENT
DEFAULT_MAX_DATA_SIZEback to summary
private static final int DEFAULT_MAX_DATA_SIZE
exchangeback to summary
private final HttpServerExchange exchange
finishListenerback to summary
private final ConduitListener<? super AjpServerResponseConduit> finishListener
FLAG_FLUSH_QUEUEDback to summary
private static final int FLAG_FLUSH_QUEUED
FLAG_READS_DONEback to summary
private static final int FLAG_READS_DONE
FLAG_STARTback to summary
private static final int FLAG_START
FLAG_WRITE_READ_BODY_CHUNK_FROM_LISTENERback to summary
private static final int FLAG_WRITE_READ_BODY_CHUNK_FROM_LISTENER
FLAG_WRITE_RESUMEDback to summary
private static final int FLAG_WRITE_RESUMED
FLAG_WRITE_SHUTDOWNback to summary
private static final int FLAG_WRITE_SHUTDOWN
FLUSH_PACKETback to summary
private static final ByteBuffer FLUSH_PACKET
HEADER_MAPback to summary
private static final Map<HttpString, Integer> HEADER_MAP
headRequestback to summary
private final boolean headRequest
logback to summary
private static final Logger log
poolback to summary
private final ByteBufferPool pool
stateback to summary
private int state

Hides io.undertow.conduits.AbstractFramedStreamSinkConduit.state.

State flags

Constructor Detail

AjpServerResponseConduitback to summary
pack-priv AjpServerResponseConduit(final StreamSinkConduit next, final ByteBufferPool pool, final HttpServerExchange exchange, ConduitListener<? super AjpServerResponseConduit> finishListener, boolean headRequest)

Method Detail

createHeaderback to summary
private ByteBuffer[] createHeader(final ByteBuffer src)
doGetRequestBodyChunkback to summary
pack-priv boolean doGetRequestBodyChunk(ByteBuffer buffer, final AjpServerRequestConduit requestChannel) throws IOException
doTerminateWritesback to summary
protected void doTerminateWrites() throws IOException

Overrides io.undertow.conduits.AbstractFramedStreamSinkConduit.doTerminateWrites.

Annotations
@Override
finishedback to summary
protected void finished()

Overrides io.undertow.conduits.AbstractFramedStreamSinkConduit.finished.

Annotations
@Override
flushback to summary
public boolean flush() throws IOException

Overrides org.xnio.conduits.AbstractSinkConduit.flush.

Implements org.xnio.conduits.SinkConduit.flush.

Doc from org.xnio.conduits.SinkConduit.flush.

Flush out any unwritten, buffered output.

Returns:boolean

true if everything is flushed, false otherwise

Exceptions
IOException:
if flush fails
isWriteResumedback to summary
public boolean isWriteResumed()

Overrides org.xnio.conduits.AbstractSinkConduit.isWriteResumed.

Implements org.xnio.conduits.SinkConduit.isWriteResumed.

Doc from org.xnio.conduits.SinkConduit.isWriteResumed.

Determine whether write notifications are currently enabled.

Returns:boolean

true if write notifications are enabled

isWriteShutdownback to summary
public boolean isWriteShutdown()

Overrides org.xnio.conduits.AbstractSinkConduit.isWriteShutdown.

Implements org.xnio.conduits.SinkConduit.isWriteShutdown.

Doc from org.xnio.conduits.SinkConduit.isWriteShutdown.

Determine whether writes have been fully shut down on this conduit.

Returns:boolean

true if writes are fully shut down, false otherwise

Annotations
@Override
processAJPHeaderback to summary
private void processAJPHeader()

Handles generating the header if required, and adding it to the frame queue. No attempt is made to actually flush this, so a gathering write can be used to actually flush the data

putHttpStringback to summary
private void putHttpString(final ByteBuffer buf, HttpString value)
putIntback to summary
private static void putInt(final ByteBuffer buf, int value)
putStringback to summary
private static void putString(final ByteBuffer buf, String value)
queueCloseFramesback to summary
protected void queueCloseFrames()

Overrides io.undertow.conduits.AbstractFramedStreamSinkConduit.queueCloseFrames.

Annotations
@Override
queueRemainingBytesback to summary
private void queueRemainingBytes(final ByteBuffer src, final ByteBuffer[] buffers)
resumeWritesback to summary
public void resumeWrites()

Overrides org.xnio.conduits.AbstractSinkConduit.resumeWrites.

Implements org.xnio.conduits.SinkConduit.resumeWrites.

Doc from org.xnio.conduits.SinkConduit.resumeWrites.

Indicate that the conduit's WriteReadyHandler should be invoked as soon as data can be written without blocking.

setWriteReadyHandlerback to summary
public void setWriteReadyHandler(WriteReadyHandler handler)

Overrides org.xnio.conduits.AbstractSinkConduit.setWriteReadyHandler.

Implements org.xnio.conduits.SinkConduit.setWriteReadyHandler.

Doc from org.xnio.conduits.SinkConduit.setWriteReadyHandler.

Set the handler which should receive readiness notifications. A filter may pass this invocation on to the filter it wraps, or it may substitute itself.

Parameters
handler:WriteReadyHandler

the filter to receive readiness notifications

Annotations
@Override
suspendWritesback to summary
public void suspendWrites()

Overrides org.xnio.conduits.AbstractSinkConduit.suspendWrites.

Implements org.xnio.conduits.SinkConduit.suspendWrites.

Doc from org.xnio.conduits.SinkConduit.suspendWrites.

Indicate that calling the conduit's WriteReadyHandler should be suspended.

transferFromback to summary
public long transferFrom(final FileChannel src, final long position, final long count) throws IOException

Overrides io.undertow.conduits.AbstractFramedStreamSinkConduit.transferFrom.

Implements org.xnio.conduits.StreamSinkConduit.transferFrom.

Doc from org.xnio.conduits.StreamSinkConduit.transferFrom.

Transfer bytes into this conduit from the given file.

Parameters
src:FileChannel

the file to read from

position:long

the position within the file from which the transfer is to begin

count:long

the number of bytes to be transferred

Returns:long

the number of bytes (possibly 0) that were actually transferred

Exceptions
IOException:
if an I/O error occurs
transferFromback to summary
public long transferFrom(final StreamSourceChannel source, final long count, final ByteBuffer throughBuffer) throws IOException

Overrides io.undertow.conduits.AbstractFramedStreamSinkConduit.transferFrom.

Implements org.xnio.conduits.StreamSinkConduit.transferFrom.

Doc from org.xnio.conduits.StreamSinkConduit.transferFrom.

Transfers bytes from the given channel source. On entry, throughBuffer will be cleared. On exit, the buffer will be flipped for emptying, and may be empty or may contain data. If this method returns a value less than count, then the remaining data in throughBuffer may contain data read from source which must be written to this channel to complete the operation.

Parameters
source:StreamSourceChannel

the source to read from

count:long

the number of bytes to be transferred

throughBuffer:ByteBuffer

the buffer to copy through.

Returns:long

the number of bytes (possibly 0) that were actually transferred, or -1 if the end of input was reached

Exceptions
IOException:
if an I/O error occurs
wakeupWritesback to summary
public void wakeupWrites()

Overrides org.xnio.conduits.AbstractSinkConduit.wakeupWrites.

Implements org.xnio.conduits.SinkConduit.wakeupWrites.

Doc from org.xnio.conduits.SinkConduit.wakeupWrites.

Indicate that the conduit's WriteReadyHandler should be invoked immediately, and then again as soon as data can be written without blocking.

writeback to summary
public int write(final ByteBuffer src) throws IOException

Overrides io.undertow.conduits.AbstractFramedStreamSinkConduit.write.

Implements org.xnio.conduits.StreamSinkConduit.write.

Doc from org.xnio.conduits.StreamSinkConduit.write.

Writes a sequence of bytes to this conduit from the given buffer.

Parameters
src:ByteBuffer

the buffer containing data to write

Returns:int

the number of bytes written, possibly 0

Exceptions
IOException:
if an error occurs
writeback to summary
public long write(final ByteBuffer[] srcs) throws IOException
writeback to summary
public long write(final ByteBuffer[] srcs, final int offset, final int length) throws IOException

Overrides io.undertow.conduits.AbstractFramedStreamSinkConduit.write.

Implements org.xnio.conduits.StreamSinkConduit.write.

Doc from org.xnio.conduits.StreamSinkConduit.write.

Writes a sequence of bytes to this conduit from the given buffers.

Parameters
srcs:ByteBuffer[]

the buffers containing data to write

offset:int

the offset into the buffer array

length:int

the number of buffers to write

Returns:long

the number of bytes written, possibly 0

Exceptions
IOException:
if an error occurs
io.undertow.server.protocol.ajp back to summary

private final Class AjpServerResponseConduit.AjpServerWriteReadyHandler

extends Object
implements WriteReadyHandler
Class Inheritance
  • java.lang.Object
  • io.undertow.server.protocol.ajp.AjpServerResponseConduit.AjpServerWriteReadyHandler
All Implemented Interfaces
org.xnio.conduits.WriteReadyHandler, org.xnio.conduits.TerminateHandler

Field Summary

Modifier and TypeField and Description
private final WriteReadyHandler

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
forceTermination()

Implements org.xnio.conduits.TerminateHandler.forceTermination.

Force the front-end channel to close, in response to XNIO worker shutdown.

public void
terminated()

Implements org.xnio.conduits.TerminateHandler.terminated.

Indicate that a previous shutdown request has successfully resulted in termination.

public void
writeReady()

Implements org.xnio.conduits.WriteReadyHandler.writeReady.

Signify that writes are ready.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

delegateback to summary
private final WriteReadyHandler delegate

Constructor Detail

AjpServerWriteReadyHandlerback to summary
private AjpServerWriteReadyHandler(WriteReadyHandler delegate)

Method Detail

forceTerminationback to summary
public void forceTermination()

Implements org.xnio.conduits.TerminateHandler.forceTermination.

Doc from org.xnio.conduits.TerminateHandler.forceTermination.

Force the front-end channel to close, in response to XNIO worker shutdown.

Annotations
@Override
terminatedback to summary
public void terminated()

Implements org.xnio.conduits.TerminateHandler.terminated.

Doc from org.xnio.conduits.TerminateHandler.terminated.

Indicate that a previous shutdown request has successfully resulted in termination.

Annotations
@Override
writeReadyback to summary
public void writeReady()

Implements org.xnio.conduits.WriteReadyHandler.writeReady.

Doc from org.xnio.conduits.WriteReadyHandler.writeReady.

Signify that writes are ready.

Annotations
@Override