Class AbstractFramedStreamSourceChannel<C extends AbstractFramedChannel<C,​R,​S>,​R extends AbstractFramedStreamSourceChannel<C,​R,​S>,​S extends AbstractFramedStreamSinkChannel<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.StreamSourceChannel
    Source channel, used to receive framed messages.
    Author:
    Stuart Douglas, Flavia Rainone
    • 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:
        transferTo in interface org.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:
        transferTo in interface org.xnio.channels.StreamSourceChannel
        Throws:
        java.io.IOException
      • getMaxStreamSize

        public long getMaxStreamSize()
      • setMaxStreamSize

        public void setMaxStreamSize​(long maxStreamSize)
      • suspendReads

        public void suspendReads()
        Specified by:
        suspendReads in interface org.xnio.channels.SuspendableReadChannel
      • complete

        protected void complete()
                         throws java.io.IOException
        Method that is invoked when all data has been read.
        Throws:
        java.io.IOException
      • isComplete

        protected boolean isComplete()
      • resumeReads

        public void resumeReads()
        Specified by:
        resumeReads in interface org.xnio.channels.SuspendableReadChannel
      • isReadResumed

        public boolean isReadResumed()
        Specified by:
        isReadResumed in interface org.xnio.channels.SuspendableReadChannel
      • wakeupReads

        public void wakeupReads()
        Specified by:
        wakeupReads in interface org.xnio.channels.SuspendableReadChannel
      • addCloseTask

        public void addCloseTask​(org.xnio.ChannelListener<R> channelListener)
      • shutdownReads

        public void shutdownReads()
                           throws java.io.IOException
        Specified by:
        shutdownReads in interface org.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:
        awaitReadable in interface org.xnio.channels.SuspendableReadChannel
        Throws:
        java.io.IOException
      • awaitReadable

        public void awaitReadable​(long l,
                                  java.util.concurrent.TimeUnit timeUnit)
                           throws java.io.IOException
        Specified by:
        awaitReadable in interface org.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 frame
        frameData - 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:
        getReadThread in interface org.xnio.channels.SuspendableReadChannel
      • getReadSetter

        public org.xnio.ChannelListener.Setter<? extends R> getReadSetter()
        Specified by:
        getReadSetter in interface org.xnio.channels.StreamSourceChannel
        Specified by:
        getReadSetter in interface org.xnio.channels.SuspendableReadChannel
      • getCloseSetter

        public org.xnio.ChannelListener.Setter<? extends R> getCloseSetter()
        Specified by:
        getCloseSetter in interface org.xnio.channels.CloseableChannel
        Specified by:
        getCloseSetter in interface org.xnio.channels.StreamSourceChannel
        Specified by:
        getCloseSetter in interface org.xnio.channels.SuspendableReadChannel
      • getWorker

        public org.xnio.XnioWorker getWorker()
        Specified by:
        getWorker in interface org.xnio.channels.CloseableChannel
      • getIoThread

        public org.xnio.XnioIoThread getIoThread()
        Specified by:
        getIoThread in interface org.xnio.channels.CloseableChannel
      • supportsOption

        public boolean supportsOption​(org.xnio.Option<?> option)
        Specified by:
        supportsOption in interface org.xnio.channels.Configurable
      • getOption

        public <T> T getOption​(org.xnio.Option<T> tOption)
                        throws java.io.IOException
        Specified by:
        getOption in interface org.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:
        setOption in interface org.xnio.channels.Configurable
        Throws:
        java.lang.IllegalArgumentException
        java.io.IOException
      • read

        public long read​(java.nio.ByteBuffer[] dsts,
                         int offset,
                         int length)
                  throws java.io.IOException
        Specified by:
        read in interface java.nio.channels.ScatteringByteChannel
        Throws:
        java.io.IOException
      • read

        public long read​(java.nio.ByteBuffer[] dsts)
                  throws java.io.IOException
        Specified by:
        read in interface java.nio.channels.ScatteringByteChannel
        Throws:
        java.io.IOException
      • read

        public int read​(java.nio.ByteBuffer dst)
                 throws java.io.IOException
        Specified by:
        read in interface java.nio.channels.ReadableByteChannel
        Throws:
        java.io.IOException
      • isOpen

        public boolean isOpen()
        Specified by:
        isOpen in interface java.nio.channels.Channel
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.nio.channels.Channel
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface org.xnio.channels.CloseableChannel
        Specified by:
        close in interface java.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.