Class DeflatingStreamSinkConduit

  • All Implemented Interfaces:
    org.xnio.conduits.Conduit, org.xnio.conduits.SinkConduit, org.xnio.conduits.StreamSinkConduit
    Direct Known Subclasses:
    GzipStreamSinkConduit

    public class DeflatingStreamSinkConduit
    extends java.lang.Object
    implements org.xnio.conduits.StreamSinkConduit
    Channel that handles deflate compression
    Author:
    Stuart Douglas
    • Field Detail

      • deflater

        protected final java.util.zip.Deflater deflater
      • currentBuffer

        protected PooledByteBuffer currentBuffer
        The streams buffer. This is freed when the next is shutdown
    • Constructor Detail

      • DeflatingStreamSinkConduit

        public DeflatingStreamSinkConduit​(ConduitFactory<org.xnio.conduits.StreamSinkConduit> conduitFactory,
                                          HttpServerExchange exchange)
      • DeflatingStreamSinkConduit

        public DeflatingStreamSinkConduit​(ConduitFactory<org.xnio.conduits.StreamSinkConduit> conduitFactory,
                                          HttpServerExchange exchange,
                                          int deflateLevel)
    • Method Detail

      • write

        public int write​(java.nio.ByteBuffer src)
                  throws java.io.IOException
        Specified by:
        write in interface org.xnio.conduits.StreamSinkConduit
        Throws:
        java.io.IOException
      • preDeflate

        protected void preDeflate​(byte[] data)
      • write

        public long write​(java.nio.ByteBuffer[] srcs,
                          int offset,
                          int length)
                   throws java.io.IOException
        Specified by:
        write in interface org.xnio.conduits.StreamSinkConduit
        Throws:
        java.io.IOException
      • writeFinal

        public int writeFinal​(java.nio.ByteBuffer src)
                       throws java.io.IOException
        Specified by:
        writeFinal in interface org.xnio.conduits.StreamSinkConduit
        Throws:
        java.io.IOException
      • writeFinal

        public long writeFinal​(java.nio.ByteBuffer[] srcs,
                               int offset,
                               int length)
                        throws java.io.IOException
        Specified by:
        writeFinal in interface org.xnio.conduits.StreamSinkConduit
        Throws:
        java.io.IOException
      • transferFrom

        public long transferFrom​(java.nio.channels.FileChannel src,
                                 long position,
                                 long count)
                          throws java.io.IOException
        Specified by:
        transferFrom in interface org.xnio.conduits.StreamSinkConduit
        Throws:
        java.io.IOException
      • transferFrom

        public long transferFrom​(org.xnio.channels.StreamSourceChannel source,
                                 long count,
                                 java.nio.ByteBuffer throughBuffer)
                          throws java.io.IOException
        Specified by:
        transferFrom in interface org.xnio.conduits.StreamSinkConduit
        Throws:
        java.io.IOException
      • getWorker

        public org.xnio.XnioWorker getWorker()
        Specified by:
        getWorker in interface org.xnio.conduits.Conduit
      • suspendWrites

        public void suspendWrites()
        Specified by:
        suspendWrites in interface org.xnio.conduits.SinkConduit
      • isWriteResumed

        public boolean isWriteResumed()
        Specified by:
        isWriteResumed in interface org.xnio.conduits.SinkConduit
      • wakeupWrites

        public void wakeupWrites()
        Specified by:
        wakeupWrites in interface org.xnio.conduits.SinkConduit
      • resumeWrites

        public void resumeWrites()
        Specified by:
        resumeWrites in interface org.xnio.conduits.SinkConduit
      • terminateWrites

        public void terminateWrites()
                             throws java.io.IOException
        Specified by:
        terminateWrites in interface org.xnio.conduits.SinkConduit
        Throws:
        java.io.IOException
      • isWriteShutdown

        public boolean isWriteShutdown()
        Specified by:
        isWriteShutdown in interface org.xnio.conduits.SinkConduit
      • awaitWritable

        public void awaitWritable()
                           throws java.io.IOException
        Specified by:
        awaitWritable in interface org.xnio.conduits.SinkConduit
        Throws:
        java.io.IOException
      • awaitWritable

        public void awaitWritable​(long time,
                                  java.util.concurrent.TimeUnit timeUnit)
                           throws java.io.IOException
        Specified by:
        awaitWritable in interface org.xnio.conduits.SinkConduit
        Throws:
        java.io.IOException
      • getWriteThread

        public org.xnio.XnioIoThread getWriteThread()
        Specified by:
        getWriteThread in interface org.xnio.conduits.SinkConduit
      • setWriteReadyHandler

        public void setWriteReadyHandler​(org.xnio.conduits.WriteReadyHandler handler)
        Specified by:
        setWriteReadyHandler in interface org.xnio.conduits.SinkConduit
      • flush

        public boolean flush()
                      throws java.io.IOException
        Specified by:
        flush in interface org.xnio.conduits.SinkConduit
        Throws:
        java.io.IOException
      • getTrailer

        protected byte[] getTrailer()
        called before the stream is finally flushed.
      • truncateWrites

        public void truncateWrites()
                            throws java.io.IOException
        Specified by:
        truncateWrites in interface org.xnio.conduits.SinkConduit
        Throws:
        java.io.IOException