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
-
-
Constructor Summary
Constructors Constructor Description AbstractFramedStreamSourceChannel(C framedChannel)
AbstractFramedStreamSourceChannel(C framedChannel, PooledByteBuffer data, long frameDataRemaining)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCloseTask(org.xnio.ChannelListener<R> channelListener)
void
awaitReadable()
void
awaitReadable(long l, TimeUnit timeUnit)
protected void
channelForciblyClosed()
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>
getCloseSetter()
protected C
getFramedChannel()
org.xnio.XnioIoThread
getIoThread()
long
getMaxStreamSize()
<T> T
getOption(org.xnio.Option<T> tOption)
protected int
getReadFrameCount()
org.xnio.ChannelListener.Setter<? extends R>
getReadSetter()
org.xnio.XnioExecutor
getReadThread()
org.xnio.XnioWorker
getWorker()
protected void
handleHeaderData(FrameHeaderData headerData)
protected boolean
isComplete()
protected boolean
isLastFrame()
boolean
isOpen()
boolean
isReadResumed()
protected void
lastFrame()
protected void
markStreamBroken()
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
resumeReads()
void
setMaxStreamSize(long maxStreamSize)
<T> T
setOption(org.xnio.Option<T> tOption, T t)
void
shutdownReads()
boolean
supportsOption(org.xnio.Option<?> option)
void
suspendReads()
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
wakeupReads()
-
-
-
Constructor Detail
-
AbstractFramedStreamSourceChannel
public AbstractFramedStreamSourceChannel(C framedChannel)
-
AbstractFramedStreamSourceChannel
public AbstractFramedStreamSourceChannel(C framedChannel, PooledByteBuffer data, long frameDataRemaining)
-
-
Method Detail
-
transferTo
public long transferTo(long position, long count, FileChannel target) throws IOException
- 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
protected void complete() throws IOException
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
public void addCloseTask(org.xnio.ChannelListener<R> channelListener)
-
shutdownReads
public void shutdownReads() throws IOException
- Specified by:
shutdownReads
in interfaceorg.xnio.channels.SuspendableReadChannel
- Throws:
IOException
-
lastFrame
protected void lastFrame()
-
isLastFrame
protected boolean isLastFrame()
-
awaitReadable
public void awaitReadable() throws IOException
- Specified by:
awaitReadable
in interfaceorg.xnio.channels.SuspendableReadChannel
- Throws:
IOException
-
awaitReadable
public void awaitReadable(long l, TimeUnit timeUnit) throws IOException
- Specified by:
awaitReadable
in interfaceorg.xnio.channels.SuspendableReadChannel
- Throws:
IOException
-
dataReady
protected void dataReady(FrameHeaderData headerData, PooledByteBuffer frameData)
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
protected long updateFrameDataRemaining(PooledByteBuffer frameData, long frameDataRemaining)
-
processFrameData
protected PooledByteBuffer processFrameData(PooledByteBuffer data, boolean lastFragmentOfFrame) throws IOException
- Throws:
IOException
-
handleHeaderData
protected void handleHeaderData(FrameHeaderData headerData)
-
getReadThread
public org.xnio.XnioExecutor getReadThread()
- Specified by:
getReadThread
in interfaceorg.xnio.channels.SuspendableReadChannel
-
getReadSetter
public org.xnio.ChannelListener.Setter<? extends R> getReadSetter()
- Specified by:
getReadSetter
in interfaceorg.xnio.channels.StreamSourceChannel
- Specified by:
getReadSetter
in interfaceorg.xnio.channels.SuspendableReadChannel
-
getCloseSetter
public org.xnio.ChannelListener.Setter<? extends R> 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
public <T> T getOption(org.xnio.Option<T> tOption) throws IOException
- 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
public long read(ByteBuffer[] dsts, int offset, int length) throws IOException
- Specified by:
read
in interfaceScatteringByteChannel
- Throws:
IOException
-
read
public long read(ByteBuffer[] dsts) throws IOException
- Specified by:
read
in interfaceScatteringByteChannel
- Throws:
IOException
-
read
public int read(ByteBuffer dst) throws IOException
- Specified by:
read
in interfaceReadableByteChannel
- Throws:
IOException
-
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
protected C 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.
-
-