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:
java.io.Closeable,java.lang.AutoCloseable,java.nio.channels.Channel,java.nio.channels.InterruptibleChannel,java.nio.channels.ReadableByteChannel,java.nio.channels.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 java.lang.Object implements org.xnio.channels.StreamSourceChannelSource 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 voidaddCloseTask(org.xnio.ChannelListener<R> channelListener)voidawaitReadable()voidawaitReadable(long l, java.util.concurrent.TimeUnit timeUnit)protected voidchannelForciblyClosed()voidclose()protected voidcomplete()Method that is invoked when all data has been read.protected voiddataReady(FrameHeaderData headerData, PooledByteBuffer frameData)Called when data has been read from the underlying channel.org.xnio.ChannelListener.Setter<? extends R>getCloseSetter()protected CgetFramedChannel()org.xnio.XnioIoThreadgetIoThread()longgetMaxStreamSize()<T> TgetOption(org.xnio.Option<T> tOption)protected intgetReadFrameCount()org.xnio.ChannelListener.Setter<? extends R>getReadSetter()org.xnio.XnioExecutorgetReadThread()org.xnio.XnioWorkergetWorker()protected voidhandleHeaderData(FrameHeaderData headerData)protected booleanisComplete()protected booleanisLastFrame()booleanisOpen()booleanisReadResumed()protected voidlastFrame()protected voidmarkStreamBroken()Called when this stream is no longer valid.protected PooledByteBufferprocessFrameData(PooledByteBuffer data, boolean lastFragmentOfFrame)intread(java.nio.ByteBuffer dst)longread(java.nio.ByteBuffer[] dsts)longread(java.nio.ByteBuffer[] dsts, int offset, int length)voidresumeReads()voidsetMaxStreamSize(long maxStreamSize)<T> TsetOption(org.xnio.Option<T> tOption, T t)voidshutdownReads()booleansupportsOption(org.xnio.Option<?> option)voidsuspendReads()longtransferTo(long position, long count, java.nio.channels.FileChannel target)longtransferTo(long count, java.nio.ByteBuffer throughBuffer, org.xnio.channels.StreamSinkChannel streamSinkChannel)protected longupdateFrameDataRemaining(PooledByteBuffer frameData, long frameDataRemaining)voidwakeupReads()
-
-
-
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, java.nio.channels.FileChannel target) throws java.io.IOException- Specified by:
transferToin interfaceorg.xnio.channels.StreamSourceChannel- Throws:
java.io.IOException
-
transferTo
public long transferTo(long count, java.nio.ByteBuffer throughBuffer, org.xnio.channels.StreamSinkChannel streamSinkChannel) throws java.io.IOException- Specified by:
transferToin interfaceorg.xnio.channels.StreamSourceChannel- Throws:
java.io.IOException
-
getMaxStreamSize
public long getMaxStreamSize()
-
setMaxStreamSize
public void setMaxStreamSize(long maxStreamSize)
-
suspendReads
public void suspendReads()
- Specified by:
suspendReadsin interfaceorg.xnio.channels.SuspendableReadChannel
-
complete
protected void complete() throws java.io.IOExceptionMethod that is invoked when all data has been read.- Throws:
java.io.IOException
-
isComplete
protected boolean isComplete()
-
resumeReads
public void resumeReads()
- Specified by:
resumeReadsin interfaceorg.xnio.channels.SuspendableReadChannel
-
isReadResumed
public boolean isReadResumed()
- Specified by:
isReadResumedin interfaceorg.xnio.channels.SuspendableReadChannel
-
wakeupReads
public void wakeupReads()
- Specified by:
wakeupReadsin interfaceorg.xnio.channels.SuspendableReadChannel
-
addCloseTask
public void addCloseTask(org.xnio.ChannelListener<R> channelListener)
-
shutdownReads
public void shutdownReads() throws java.io.IOException- Specified by:
shutdownReadsin interfaceorg.xnio.channels.SuspendableReadChannel- Throws:
java.io.IOException
-
lastFrame
protected void lastFrame()
-
isLastFrame
protected boolean isLastFrame()
-
awaitReadable
public void awaitReadable() throws java.io.IOException- Specified by:
awaitReadablein interfaceorg.xnio.channels.SuspendableReadChannel- Throws:
java.io.IOException
-
awaitReadable
public void awaitReadable(long l, java.util.concurrent.TimeUnit timeUnit) throws java.io.IOException- Specified by:
awaitReadablein interfaceorg.xnio.channels.SuspendableReadChannel- Throws:
java.io.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 java.io.IOException
- Throws:
java.io.IOException
-
handleHeaderData
protected void handleHeaderData(FrameHeaderData headerData)
-
getReadThread
public org.xnio.XnioExecutor getReadThread()
- Specified by:
getReadThreadin interfaceorg.xnio.channels.SuspendableReadChannel
-
getReadSetter
public org.xnio.ChannelListener.Setter<? extends R> getReadSetter()
- Specified by:
getReadSetterin interfaceorg.xnio.channels.StreamSourceChannel- Specified by:
getReadSetterin interfaceorg.xnio.channels.SuspendableReadChannel
-
getCloseSetter
public org.xnio.ChannelListener.Setter<? extends R> getCloseSetter()
- Specified by:
getCloseSetterin interfaceorg.xnio.channels.CloseableChannel- Specified by:
getCloseSetterin interfaceorg.xnio.channels.StreamSourceChannel- Specified by:
getCloseSetterin interfaceorg.xnio.channels.SuspendableReadChannel
-
getWorker
public org.xnio.XnioWorker getWorker()
- Specified by:
getWorkerin interfaceorg.xnio.channels.CloseableChannel
-
getIoThread
public org.xnio.XnioIoThread getIoThread()
- Specified by:
getIoThreadin interfaceorg.xnio.channels.CloseableChannel
-
supportsOption
public boolean supportsOption(org.xnio.Option<?> option)
- Specified by:
supportsOptionin interfaceorg.xnio.channels.Configurable
-
getOption
public <T> T getOption(org.xnio.Option<T> tOption) throws java.io.IOException- Specified by:
getOptionin interfaceorg.xnio.channels.Configurable- Throws:
java.io.IOException
-
setOption
public <T> T setOption(org.xnio.Option<T> tOption, T t) throws java.lang.IllegalArgumentException, java.io.IOException- Specified by:
setOptionin interfaceorg.xnio.channels.Configurable- Throws:
java.lang.IllegalArgumentExceptionjava.io.IOException
-
read
public long read(java.nio.ByteBuffer[] dsts, int offset, int length) throws java.io.IOException- Specified by:
readin interfacejava.nio.channels.ScatteringByteChannel- Throws:
java.io.IOException
-
read
public long read(java.nio.ByteBuffer[] dsts) throws java.io.IOException- Specified by:
readin interfacejava.nio.channels.ScatteringByteChannel- Throws:
java.io.IOException
-
read
public int read(java.nio.ByteBuffer dst) throws java.io.IOException- Specified by:
readin interfacejava.nio.channels.ReadableByteChannel- Throws:
java.io.IOException
-
isOpen
public boolean isOpen()
- Specified by:
isOpenin interfacejava.nio.channels.Channel
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.nio.channels.Channel- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein interfaceorg.xnio.channels.CloseableChannel- Specified by:
closein interfacejava.nio.channels.InterruptibleChannel
-
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.
-
-