Class CompressExtension
- java.lang.Object
-
- org.eclipse.jetty.util.component.AbstractLifeCycle
-
- org.eclipse.jetty.websocket.common.extensions.AbstractExtension
-
- org.eclipse.jetty.websocket.common.extensions.compress.CompressExtension
-
- All Implemented Interfaces:
org.eclipse.jetty.util.component.LifeCycle,Extension,IncomingFrames,OutgoingFrames
- Direct Known Subclasses:
DeflateFrameExtension,PerMessageDeflateExtension
public abstract class CompressExtension extends AbstractExtension
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classCompressExtension.Flusherprivate static classCompressExtension.FrameEntry
-
Field Summary
Fields Modifier and Type Field Description private static intDECOMPRESS_BUF_SIZEInflater : Output Buffer Sizeprotected java.util.concurrent.atomic.AtomicIntegerdecompressCountprivate java.util.zip.DeflaterdeflaterImplprivate org.eclipse.jetty.util.compression.DeflaterPooldeflaterPoolprivate java.util.Queue<CompressExtension.FrameEntry>entriesprivate org.eclipse.jetty.util.IteratingCallbackflusherprotected static intINFLATE_BUFFER_SIZEInflater / Decompressed Buffer Sizeprivate java.util.zip.InflaterinflaterImplprivate org.eclipse.jetty.util.compression.InflaterPoolinflaterPoolprotected static intINPUT_MAX_BUFFER_SIZEDeflater / Inflater: Maximum Input Buffer Sizeprivate static org.eclipse.jetty.util.log.LoggerLOGprotected static intRSV_USE_ALWAYSAlways set RSV flag, on all frame typesprotected static intRSV_USE_ONLY_FIRSTOnly set RSV flag on first frame in multi-frame messages.private intrsvUseprotected static byte[]TAIL_BYTESprotected static java.nio.ByteBufferTAIL_BYTES_BUFprotected static intTAIL_DROP_ALWAYSAlways drop tail bytes 0000FFFF, from all frame typesprotected static intTAIL_DROP_FIN_ONLYOnly drop tail bytes 0000FFFF, from fin==true framesprotected static intTAIL_DROP_NEVERNever drop tail bytes 0000FFFF, from any frame typeprivate inttailDrop
-
Constructor Summary
Constructors Modifier Constructor Description protectedCompressExtension()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voiddecompress(ByteAccumulator accumulator, java.nio.ByteBuffer buf)protected voiddoStop()static booleanendsWithTail(java.nio.ByteBuffer buf)protected voidforwardIncoming(Frame frame, ByteAccumulator accumulator)java.util.zip.DeflatergetDeflater()java.util.zip.InflatergetInflater()(package private) abstract intgetRsvUseMode()Return the mode of operation for RSV flag use in frames generate by compress (outgoing)(package private) abstract intgetTailDropMode()Return the mode of operation for dropping (or keeping) tail bytes in frames generated by compress (outgoing)booleanisRsv1User()Indicates use of RSV1 flag for indicating deflation is in use.protected ByteAccumulatornewByteAccumulator()protected voidnotifyCallbackFailure(WriteCallback callback, java.lang.Throwable failure)protected voidnotifyCallbackSuccess(WriteCallback callback)private voidofferEntry(CompressExtension.FrameEntry entry)voidoutgoingFrame(Frame frame, WriteCallback callback, BatchMode batchMode)A frame, and optional callback, intended for the network layer.private CompressExtension.FrameEntrypollEntry()voidsetDeflaterPool(org.eclipse.jetty.util.compression.DeflaterPool deflaterPool)voidsetInflaterPool(org.eclipse.jetty.util.compression.InflaterPool inflaterPool)private static booleansupplyInput(java.util.zip.Deflater deflater, java.nio.ByteBuffer buf)private static booleansupplyInput(java.util.zip.Inflater inflater, java.nio.ByteBuffer buf)private static java.lang.StringtoDetail(java.util.zip.Deflater deflater)private static java.lang.StringtoDetail(java.util.zip.Inflater inflater)java.lang.StringtoString()-
Methods inherited from class org.eclipse.jetty.websocket.common.extensions.AbstractExtension
getBufferPool, getConfig, getConnection, getName, getNextIncoming, getNextOutgoing, getPolicy, init, init, isRsv2User, isRsv3User, nextIncomingFrame, nextOutgoingFrame, setBufferPool, setConfig, setConnection, setNextIncomingFrames, setNextOutgoingFrames, setPolicy
-
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
addLifeCycleListener, doStart, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, setStopTimeout, start, stop
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.jetty.websocket.api.extensions.IncomingFrames
incomingFrame
-
-
-
-
Field Detail
-
TAIL_BYTES
protected static final byte[] TAIL_BYTES
-
TAIL_BYTES_BUF
protected static final java.nio.ByteBuffer TAIL_BYTES_BUF
-
LOG
private static final org.eclipse.jetty.util.log.Logger LOG
-
TAIL_DROP_NEVER
protected static final int TAIL_DROP_NEVER
Never drop tail bytes 0000FFFF, from any frame type- See Also:
- Constant Field Values
-
TAIL_DROP_ALWAYS
protected static final int TAIL_DROP_ALWAYS
Always drop tail bytes 0000FFFF, from all frame types- See Also:
- Constant Field Values
-
TAIL_DROP_FIN_ONLY
protected static final int TAIL_DROP_FIN_ONLY
Only drop tail bytes 0000FFFF, from fin==true frames- See Also:
- Constant Field Values
-
RSV_USE_ALWAYS
protected static final int RSV_USE_ALWAYS
Always set RSV flag, on all frame types- See Also:
- Constant Field Values
-
RSV_USE_ONLY_FIRST
protected static final int RSV_USE_ONLY_FIRST
Only set RSV flag on first frame in multi-frame messages.Note: this automatically means no-continuation frames have the RSV bit set
- See Also:
- Constant Field Values
-
INFLATE_BUFFER_SIZE
protected static final int INFLATE_BUFFER_SIZE
Inflater / Decompressed Buffer Size- See Also:
- Constant Field Values
-
INPUT_MAX_BUFFER_SIZE
protected static final int INPUT_MAX_BUFFER_SIZE
Deflater / Inflater: Maximum Input Buffer Size- See Also:
- Constant Field Values
-
DECOMPRESS_BUF_SIZE
private static final int DECOMPRESS_BUF_SIZE
Inflater : Output Buffer Size- See Also:
- Constant Field Values
-
entries
private final java.util.Queue<CompressExtension.FrameEntry> entries
-
flusher
private final org.eclipse.jetty.util.IteratingCallback flusher
-
deflaterPool
private org.eclipse.jetty.util.compression.DeflaterPool deflaterPool
-
inflaterPool
private org.eclipse.jetty.util.compression.InflaterPool inflaterPool
-
deflaterImpl
private java.util.zip.Deflater deflaterImpl
-
inflaterImpl
private java.util.zip.Inflater inflaterImpl
-
decompressCount
protected java.util.concurrent.atomic.AtomicInteger decompressCount
-
tailDrop
private int tailDrop
-
rsvUse
private int rsvUse
-
-
Method Detail
-
setInflaterPool
public void setInflaterPool(org.eclipse.jetty.util.compression.InflaterPool inflaterPool)
-
setDeflaterPool
public void setDeflaterPool(org.eclipse.jetty.util.compression.DeflaterPool deflaterPool)
-
getDeflater
public java.util.zip.Deflater getDeflater()
-
getInflater
public java.util.zip.Inflater getInflater()
-
isRsv1User
public boolean isRsv1User()
Indicates use of RSV1 flag for indicating deflation is in use.- Specified by:
isRsv1Userin interfaceExtension- Overrides:
isRsv1Userin classAbstractExtension- Returns:
- true if extension uses RSV1 for its own purposes.
-
getTailDropMode
abstract int getTailDropMode()
Return the mode of operation for dropping (or keeping) tail bytes in frames generated by compress (outgoing)- Returns:
- either
TAIL_DROP_ALWAYS,TAIL_DROP_FIN_ONLY, orTAIL_DROP_NEVER
-
getRsvUseMode
abstract int getRsvUseMode()
Return the mode of operation for RSV flag use in frames generate by compress (outgoing)- Returns:
- either
RSV_USE_ALWAYSorRSV_USE_ONLY_FIRST
-
forwardIncoming
protected void forwardIncoming(Frame frame, ByteAccumulator accumulator)
-
newByteAccumulator
protected ByteAccumulator newByteAccumulator()
-
decompress
protected void decompress(ByteAccumulator accumulator, java.nio.ByteBuffer buf) throws java.util.zip.DataFormatException
- Throws:
java.util.zip.DataFormatException
-
outgoingFrame
public void outgoingFrame(Frame frame, WriteCallback callback, BatchMode batchMode)
Description copied from interface:OutgoingFramesA frame, and optional callback, intended for the network layer.Note: the frame can undergo many transformations in the various layers and extensions present in the implementation.
If you are implementing a mutation, you are obliged to handle the incoming WriteCallback appropriately.
- Parameters:
frame- the frame to eventually write to the network layer.callback- the callback to notify when the frame is written.batchMode- the batch mode requested by the sender.
-
offerEntry
private void offerEntry(CompressExtension.FrameEntry entry)
-
pollEntry
private CompressExtension.FrameEntry pollEntry()
-
notifyCallbackSuccess
protected void notifyCallbackSuccess(WriteCallback callback)
-
notifyCallbackFailure
protected void notifyCallbackFailure(WriteCallback callback, java.lang.Throwable failure)
-
supplyInput
private static boolean supplyInput(java.util.zip.Inflater inflater, java.nio.ByteBuffer buf)
-
supplyInput
private static boolean supplyInput(java.util.zip.Deflater deflater, java.nio.ByteBuffer buf)
-
toDetail
private static java.lang.String toDetail(java.util.zip.Inflater inflater)
-
toDetail
private static java.lang.String toDetail(java.util.zip.Deflater deflater)
-
endsWithTail
public static boolean endsWithTail(java.nio.ByteBuffer buf)
-
doStop
protected void doStop() throws java.lang.Exception- Overrides:
doStopin classorg.eclipse.jetty.util.component.AbstractLifeCycle- Throws:
java.lang.Exception
-
toString
public java.lang.String toString()
- Overrides:
toStringin classAbstractExtension
-
-