Package io.undertow.conduits
Class DeflatingStreamSinkConduit
- java.lang.Object
-
- io.undertow.conduits.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.StreamSinkConduitChannel that handles deflate compression- Author:
- Stuart Douglas
-
-
Field Summary
Fields Modifier and Type Field Description protected PooledByteBuffercurrentBufferThe streams buffer.protected java.util.zip.Deflaterdeflaterprotected PooledObject<java.util.zip.Deflater>pooledObject
-
Constructor Summary
Constructors Constructor Description DeflatingStreamSinkConduit(ConduitFactory<org.xnio.conduits.StreamSinkConduit> conduitFactory, HttpServerExchange exchange)DeflatingStreamSinkConduit(ConduitFactory<org.xnio.conduits.StreamSinkConduit> conduitFactory, HttpServerExchange exchange, int deflateLevel)DeflatingStreamSinkConduit(ConduitFactory<org.xnio.conduits.StreamSinkConduit> conduitFactory, HttpServerExchange exchange, ObjectPool<java.util.zip.Deflater> deflaterPool)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidawaitWritable()voidawaitWritable(long time, java.util.concurrent.TimeUnit timeUnit)booleanflush()protected byte[]getTrailer()called before the stream is finally flushed.org.xnio.XnioWorkergetWorker()org.xnio.XnioIoThreadgetWriteThread()booleanisWriteResumed()booleanisWriteShutdown()static ObjectPool<java.util.zip.Deflater>newInstanceDeflaterPool(int deflateLevel)protected voidpostDeflate(java.nio.ByteBuffer data)voidresumeWrites()voidsetWriteReadyHandler(org.xnio.conduits.WriteReadyHandler handler)static ObjectPool<java.util.zip.Deflater>simpleDeflaterPool(int poolSize, int deflateLevel)voidsuspendWrites()voidterminateWrites()longtransferFrom(java.nio.channels.FileChannel src, long position, long count)longtransferFrom(org.xnio.channels.StreamSourceChannel source, long count, java.nio.ByteBuffer throughBuffer)voidtruncateWrites()voidwakeupWrites()intwrite(java.nio.ByteBuffer src)longwrite(java.nio.ByteBuffer[] srcs, int offset, int length)intwriteFinal(java.nio.ByteBuffer src)longwriteFinal(java.nio.ByteBuffer[] srcs, int offset, int length)
-
-
-
Field Detail
-
deflater
protected volatile java.util.zip.Deflater deflater
-
pooledObject
protected final PooledObject<java.util.zip.Deflater> pooledObject
-
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)
-
DeflatingStreamSinkConduit
public DeflatingStreamSinkConduit(ConduitFactory<org.xnio.conduits.StreamSinkConduit> conduitFactory, HttpServerExchange exchange, ObjectPool<java.util.zip.Deflater> deflaterPool)
-
-
Method Detail
-
newInstanceDeflaterPool
public static ObjectPool<java.util.zip.Deflater> newInstanceDeflaterPool(int deflateLevel)
-
simpleDeflaterPool
public static ObjectPool<java.util.zip.Deflater> simpleDeflaterPool(int poolSize, int deflateLevel)
-
write
public int write(java.nio.ByteBuffer src) throws java.io.IOException- Specified by:
writein interfaceorg.xnio.conduits.StreamSinkConduit- Throws:
java.io.IOException
-
postDeflate
protected void postDeflate(java.nio.ByteBuffer data)
-
write
public long write(java.nio.ByteBuffer[] srcs, int offset, int length) throws java.io.IOException- Specified by:
writein interfaceorg.xnio.conduits.StreamSinkConduit- Throws:
java.io.IOException
-
writeFinal
public int writeFinal(java.nio.ByteBuffer src) throws java.io.IOException- Specified by:
writeFinalin interfaceorg.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:
writeFinalin interfaceorg.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:
transferFromin interfaceorg.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:
transferFromin interfaceorg.xnio.conduits.StreamSinkConduit- Throws:
java.io.IOException
-
getWorker
public org.xnio.XnioWorker getWorker()
- Specified by:
getWorkerin interfaceorg.xnio.conduits.Conduit
-
suspendWrites
public void suspendWrites()
- Specified by:
suspendWritesin interfaceorg.xnio.conduits.SinkConduit
-
isWriteResumed
public boolean isWriteResumed()
- Specified by:
isWriteResumedin interfaceorg.xnio.conduits.SinkConduit
-
wakeupWrites
public void wakeupWrites()
- Specified by:
wakeupWritesin interfaceorg.xnio.conduits.SinkConduit
-
resumeWrites
public void resumeWrites()
- Specified by:
resumeWritesin interfaceorg.xnio.conduits.SinkConduit
-
terminateWrites
public void terminateWrites() throws java.io.IOException- Specified by:
terminateWritesin interfaceorg.xnio.conduits.SinkConduit- Throws:
java.io.IOException
-
isWriteShutdown
public boolean isWriteShutdown()
- Specified by:
isWriteShutdownin interfaceorg.xnio.conduits.SinkConduit
-
awaitWritable
public void awaitWritable() throws java.io.IOException- Specified by:
awaitWritablein interfaceorg.xnio.conduits.SinkConduit- Throws:
java.io.IOException
-
awaitWritable
public void awaitWritable(long time, java.util.concurrent.TimeUnit timeUnit) throws java.io.IOException- Specified by:
awaitWritablein interfaceorg.xnio.conduits.SinkConduit- Throws:
java.io.IOException
-
getWriteThread
public org.xnio.XnioIoThread getWriteThread()
- Specified by:
getWriteThreadin interfaceorg.xnio.conduits.SinkConduit
-
setWriteReadyHandler
public void setWriteReadyHandler(org.xnio.conduits.WriteReadyHandler handler)
- Specified by:
setWriteReadyHandlerin interfaceorg.xnio.conduits.SinkConduit
-
flush
public boolean flush() throws java.io.IOException- Specified by:
flushin interfaceorg.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:
truncateWritesin interfaceorg.xnio.conduits.SinkConduit- Throws:
java.io.IOException
-
-