Class AbstractFramedStreamSourceChannel<C extends AbstractFramedChannel<C,R,S>,R extends AbstractFramedStreamSourceChannel<C,R,S>,S extends AbstractFramedStreamSinkChannel<C,R,S>>
java.lang.Object
io.undertow.server.protocol.framed.AbstractFramedStreamSourceChannel<C,R,S>
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Channel
,InterruptibleChannel
,ReadableByteChannel
,ScatteringByteChannel
,org.xnio.channels.CloseableChannel
,org.xnio.channels.Configurable
,org.xnio.channels.StreamSourceChannel
,org.xnio.channels.SuspendableReadChannel
- Direct Known Subclasses:
AbstractAjpClientStreamSourceChannel
,AbstractHttp2StreamSourceChannel
,StreamSourceFrameChannel
public abstract class AbstractFramedStreamSourceChannel<C extends AbstractFramedChannel<C,R,S>,R extends AbstractFramedStreamSourceChannel<C,R,S>,S extends AbstractFramedStreamSinkChannel<C,R,S>>
extends Object
implements org.xnio.channels.StreamSourceChannel
Source channel, used to receive framed messages.
- Author:
- Stuart Douglas, Flavia Rainone
-
Field Summary
Fields inherited from interface org.xnio.channels.Configurable
EMPTY
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractFramedStreamSourceChannel
(C framedChannel) AbstractFramedStreamSourceChannel
(C framedChannel, PooledByteBuffer data, long frameDataRemaining) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCloseTask
(org.xnio.ChannelListener<R> channelListener) void
void
awaitReadable
(long l, TimeUnit timeUnit) protected void
void
close()
protected void
complete()
Method that is invoked when all data has been read.protected void
dataReady
(FrameHeaderData headerData, PooledByteBuffer frameData) Called when data has been read from the underlying channel.org.xnio.ChannelListener.Setter<? extends R>
protected C
org.xnio.XnioIoThread
long
<T> T
getOption
(org.xnio.Option<T> tOption) protected int
org.xnio.ChannelListener.Setter<? extends R>
org.xnio.XnioExecutor
org.xnio.XnioWorker
protected void
handleHeaderData
(FrameHeaderData headerData) protected boolean
protected boolean
boolean
isOpen()
boolean
protected void
protected void
Called when this stream is no longer valid.protected PooledByteBuffer
processFrameData
(PooledByteBuffer data, boolean lastFragmentOfFrame) int
read
(ByteBuffer dst) long
read
(ByteBuffer[] dsts) long
read
(ByteBuffer[] dsts, int offset, int length) void
void
setMaxStreamSize
(long maxStreamSize) <T> T
setOption
(org.xnio.Option<T> tOption, T t) void
boolean
supportsOption
(org.xnio.Option<?> option) void
long
transferTo
(long position, long count, FileChannel target) long
transferTo
(long count, ByteBuffer throughBuffer, org.xnio.channels.StreamSinkChannel streamSinkChannel) protected long
updateFrameDataRemaining
(PooledByteBuffer frameData, long frameDataRemaining) void
-
Constructor Details
-
AbstractFramedStreamSourceChannel
-
AbstractFramedStreamSourceChannel
public AbstractFramedStreamSourceChannel(C framedChannel, PooledByteBuffer data, long frameDataRemaining)
-
-
Method Details
-
transferTo
- Specified by:
transferTo
in interfaceorg.xnio.channels.StreamSourceChannel
- Throws:
IOException
-
transferTo
public long transferTo(long count, ByteBuffer throughBuffer, org.xnio.channels.StreamSinkChannel streamSinkChannel) throws IOException - Specified by:
transferTo
in interfaceorg.xnio.channels.StreamSourceChannel
- Throws:
IOException
-
getMaxStreamSize
public long getMaxStreamSize() -
setMaxStreamSize
public void setMaxStreamSize(long maxStreamSize) -
suspendReads
public void suspendReads()- Specified by:
suspendReads
in interfaceorg.xnio.channels.SuspendableReadChannel
-
complete
Method that is invoked when all data has been read.- Throws:
IOException
-
isComplete
protected boolean isComplete() -
resumeReads
public void resumeReads()- Specified by:
resumeReads
in interfaceorg.xnio.channels.SuspendableReadChannel
-
isReadResumed
public boolean isReadResumed()- Specified by:
isReadResumed
in interfaceorg.xnio.channels.SuspendableReadChannel
-
wakeupReads
public void wakeupReads()- Specified by:
wakeupReads
in interfaceorg.xnio.channels.SuspendableReadChannel
-
addCloseTask
-
shutdownReads
- Specified by:
shutdownReads
in interfaceorg.xnio.channels.SuspendableReadChannel
- Throws:
IOException
-
lastFrame
protected void lastFrame() -
isLastFrame
protected boolean isLastFrame() -
awaitReadable
- Specified by:
awaitReadable
in interfaceorg.xnio.channels.SuspendableReadChannel
- Throws:
IOException
-
awaitReadable
- Specified by:
awaitReadable
in interfaceorg.xnio.channels.SuspendableReadChannel
- Throws:
IOException
-
dataReady
Called when data has been read from the underlying channel.- Parameters:
headerData
- The frame header data. This may be null if the data is part of a an existing frameframeData
- The frame data
-
updateFrameDataRemaining
-
processFrameData
protected PooledByteBuffer processFrameData(PooledByteBuffer data, boolean lastFragmentOfFrame) throws IOException - Throws:
IOException
-
handleHeaderData
-
getReadThread
public org.xnio.XnioExecutor getReadThread()- Specified by:
getReadThread
in interfaceorg.xnio.channels.SuspendableReadChannel
-
getReadSetter
- Specified by:
getReadSetter
in interfaceorg.xnio.channels.StreamSourceChannel
- Specified by:
getReadSetter
in interfaceorg.xnio.channels.SuspendableReadChannel
-
getCloseSetter
- Specified by:
getCloseSetter
in interfaceorg.xnio.channels.CloseableChannel
- Specified by:
getCloseSetter
in interfaceorg.xnio.channels.StreamSourceChannel
- Specified by:
getCloseSetter
in interfaceorg.xnio.channels.SuspendableReadChannel
-
getWorker
public org.xnio.XnioWorker getWorker()- Specified by:
getWorker
in interfaceorg.xnio.channels.CloseableChannel
-
getIoThread
public org.xnio.XnioIoThread getIoThread()- Specified by:
getIoThread
in interfaceorg.xnio.channels.CloseableChannel
-
supportsOption
public boolean supportsOption(org.xnio.Option<?> option) - Specified by:
supportsOption
in interfaceorg.xnio.channels.Configurable
-
getOption
- Specified by:
getOption
in interfaceorg.xnio.channels.Configurable
- Throws:
IOException
-
setOption
public <T> T setOption(org.xnio.Option<T> tOption, T t) throws IllegalArgumentException, IOException - Specified by:
setOption
in interfaceorg.xnio.channels.Configurable
- Throws:
IllegalArgumentException
IOException
-
read
- Specified by:
read
in interfaceScatteringByteChannel
- Throws:
IOException
-
read
- Specified by:
read
in interfaceScatteringByteChannel
- Throws:
IOException
-
read
- Specified by:
read
in interfaceReadableByteChannel
- Throws:
IOException
-
isOpen
public boolean isOpen() -
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceChannel
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceorg.xnio.channels.CloseableChannel
- Specified by:
close
in interfaceInterruptibleChannel
-
channelForciblyClosed
protected void channelForciblyClosed() -
getFramedChannel
-
getReadFrameCount
protected int getReadFrameCount() -
markStreamBroken
protected void markStreamBroken()Called when this stream is no longer valid. Reads from the stream will result in an exception.
-