Class Compression
java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.ContainerLifeCycle
org.eclipse.jetty.compression.Compression
- All Implemented Interfaces:
Container
,Destroyable
,Dumpable
,Dumpable.DumpableContainer
,LifeCycle
- Direct Known Subclasses:
BrotliCompression
,GzipCompression
,ZstandardCompression
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener, AbstractLifeCycle.StopException
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
Container.InheritedListener, Container.Listener
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainer, Dumpable.DumpAppendable
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract RetainableByteBuffer.Mutable
acquireByteBuffer
(int length) Acquire aRetainableByteBuffer
that is managed by thisCompression
implementation which is suitable for compressed output from anEncoderSink
or compressed input from aDecoderSource
.protected void
doStart()
Starts the managed lifecycle beans in the order they were added.Get an etag with suffix that represents this compression implementation.int
Get the container being used for common components.abstract HttpField
TheHttpField
forContent-Encoding
suitable for this Compression implementation.abstract DecoderConfig
abstract EncoderConfig
The name of the encoding if seen in the HTTP protocol in fields likeContent-Encoding
orAccept-Encoding
.Get the ETag suffix.The filename extensions for this compression implementation.int
abstract String
getName()
abstract HttpField
TheHttpField
forX-Content-Encoding
suitable for this Compression implementation.Create a newInputStream
to decode (decompress) with this compression implementation.abstract InputStream
newDecoderInputStream
(InputStream in, DecoderConfig config) Create a newInputStream
to decode (decompress) with this compression implementation.newDecoderSource
(Content.Source source) Create a newDecoderSource
for this compression implementationabstract DecoderSource
newDecoderSource
(Content.Source source, DecoderConfig config) Create a newDecoderSource
for this compression implementationCreate a newOutputStream
to encode (compress) with this compression implementation.abstract OutputStream
newEncoderOutputStream
(OutputStream out, EncoderConfig config) Create a newOutputStream
to encode (compress) with this compression implementation.newEncoderSink
(Content.Sink sink) Create a newEncoderSink
for this compression implementationabstract EncoderSink
newEncoderSink
(Content.Sink sink, EncoderConfig config) Create a newEncoderSink
for this compression implementationvoid
setBufferSize
(int size) void
setByteBufferPool
(ByteBufferPool byteBufferPool) void
setContainer
(Container container) Set the container that this compression implementation should use.abstract void
setDefaultDecoderConfig
(DecoderConfig decoderConfig) abstract void
setDefaultEncoderConfig
(EncoderConfig encoderConfig) void
setMinCompressSize
(int minCompressSize) stripSuffixes
(String etagsList) Strip compression suffixes off etagsMethods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, destroy, doStop, dump, dump, dump, dumpObjects, dumpStdErr, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, installBean, installBean, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, start, stop, unmanage, updateBean, updateBean, updateBeans, updateBeans
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, setEventListeners, start, stop, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.jetty.util.component.Container
getCachedBeans, getEventListeners
Methods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpable
-
Constructor Details
-
Compression
-
-
Method Details
-
acquireByteBuffer
Acquire aRetainableByteBuffer
that is managed by thisCompression
implementation which is suitable for compressed output from anEncoderSink
or compressed input from aDecoderSource
.It is recommended to use this method so that any compression specific details can be managed by this Compression implementation (such as ByteOrder or buffer pooling)
- Parameters:
length
- the requested size of the buffer- Returns:
- the ByteBuffer suitable for this compression implementation.
-
etag
-
getBufferSize
public int getBufferSize() -
setBufferSize
public void setBufferSize(int size) -
getByteBufferPool
-
setByteBufferPool
-
getContainer
Get the container being used for common components.- Returns:
- the container for common components
-
setContainer
Set the container that this compression implementation should use.The container is often a source for common components (beans) that can be shared across different implementations.
- Parameters:
container
- the container (often the Server itself).
-
getContentEncodingField
-
getDefaultDecoderConfig
-
setDefaultDecoderConfig
-
getDefaultEncoderConfig
-
setDefaultEncoderConfig
-
getEncodingName
The name of the encoding if seen in the HTTP protocol in fields likeContent-Encoding
orAccept-Encoding
. This name is also reused for theETag
representations of the compressed content.- Returns:
- the name of the Content-Encoding for this compression implementation.
-
getEtagSuffix
-
getFileExtensionNames
The filename extensions for this compression implementation.Not an exhaustive list, just the most commonly seen extensions.
- Returns:
- the list of common extension names (all lowercase) for this compression implementation. ordered by most common to least common.
-
getMinCompressSize
public int getMinCompressSize() -
setMinCompressSize
public void setMinCompressSize(int minCompressSize) -
getName
- Returns:
- the name of the compression implementation.
-
getXContentEncodingField
-
newDecoderInputStream
Create a newInputStream
to decode (decompress) with this compression implementation.- Parameters:
in
- the input stream to write the decoded (decompressed) bytes to- Returns:
- the
InputStream
implementation for this compression. - Throws:
IOException
- if unable to create InputStream
-
newDecoderInputStream
public abstract InputStream newDecoderInputStream(InputStream in, DecoderConfig config) throws IOException Create a newInputStream
to decode (decompress) with this compression implementation.- Parameters:
in
- the input stream to write the decoded (decompressed) bytes toconfig
- theDecoderConfig
for this input stream.- Returns:
- the
InputStream
implementation for this compression. - Throws:
IOException
- if unable to create InputStream
-
newDecoderSource
Create a newDecoderSource
for this compression implementation- Parameters:
source
- the source to write the decoded bytes to- Returns:
- a new
DecoderSource
-
newDecoderSource
Create a newDecoderSource
for this compression implementation- Parameters:
source
- the source to write the decoded bytes toconfig
- theDecoderConfig
for this source.- Returns:
- a new
DecoderSource
-
newEncoderOutputStream
Create a newOutputStream
to encode (compress) with this compression implementation.- Parameters:
out
- the output stream to write the encoded (compressed) bytes to- Returns:
- the
OutputStream
implementation for this compression. - Throws:
IOException
- if unable to create OutputStream
-
newEncoderOutputStream
public abstract OutputStream newEncoderOutputStream(OutputStream out, EncoderConfig config) throws IOException Create a newOutputStream
to encode (compress) with this compression implementation.- Parameters:
out
- the output stream to write the encoded (compressed) bytes toconfig
- theEncoderConfig
for this output stream.- Returns:
- the
OutputStream
implementation for this compression. - Throws:
IOException
- if unable to create OutputStream
-
newEncoderSink
Create a newEncoderSink
for this compression implementation- Parameters:
sink
- the sink to write the encoded bytes to- Returns:
- a new
EncoderSink
-
newEncoderSink
Create a newEncoderSink
for this compression implementation- Parameters:
sink
- the sink to write the encoded bytes toconfig
- theEncoderConfig
for this sink.- Returns:
- a new
EncoderSink
-
stripSuffixes
-
doStart
Description copied from class:ContainerLifeCycle
Starts the managed lifecycle beans in the order they were added.- Overrides:
doStart
in classContainerLifeCycle
- Throws:
Exception
- If there was a problem starting. Will cause a transition to FAILED state
-