Package org.eclipse.jetty.compression
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.StopExceptionNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
Container.InheritedListener, Container.ListenerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainer, Dumpable.DumpAppendableNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener -
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract RetainableByteBuffer.MutableacquireByteBuffer(int length) Acquire aRetainableByteBufferthat is managed by thisCompressionimplementation which is suitable for compressed output from anEncoderSinkor compressed input from aDecoderSource.protected voiddoStart()Starts the managed lifecycle beans in the order they were added.Get an etag with suffix that represents this compression implementation.intDeprecated, for removal: This API element is subject to removal in a future version.Get the container being used for common components.abstract HttpFieldTheHttpFieldforContent-Encodingsuitable for this Compression implementation.abstract DecoderConfigabstract EncoderConfigThe name of the encoding if seen in the HTTP protocol in fields likeContent-EncodingorAccept-Encoding.Get the ETag suffix.The filename extensions for this compression implementation.intabstract StringgetName()abstract HttpFieldTheHttpFieldforX-Content-Encodingsuitable for this Compression implementation.Create a newInputStreamto decode (decompress) with this compression implementation.abstract InputStreamnewDecoderInputStream(InputStream in, DecoderConfig config) Create a newInputStreamto decode (decompress) with this compression implementation.newDecoderSource(Content.Source source) Create a newDecoderSourcefor this compression implementationabstract DecoderSourcenewDecoderSource(Content.Source source, DecoderConfig config) Create a newDecoderSourcefor this compression implementationCreate a newOutputStreamto encode (compress) with this compression implementation.abstract OutputStreamnewEncoderOutputStream(OutputStream out, EncoderConfig config) Create a newOutputStreamto encode (compress) with this compression implementation.newEncoderSink(Content.Sink sink) Create a newEncoderSinkfor this compression implementationabstract EncoderSinknewEncoderSink(Content.Sink sink, EncoderConfig config) Create a newEncoderSinkfor this compression implementationvoidsetBufferSize(int size) Deprecated, for removal: This API element is subject to removal in a future version.useEncoderConfig.setBufferSize(int)orDecoderConfig.setBufferSize(int)instead.voidsetByteBufferPool(ByteBufferPool byteBufferPool) voidsetContainer(Container container) Set the container that this compression implementation should use.abstract voidsetDefaultDecoderConfig(DecoderConfig decoderConfig) abstract voidsetDefaultEncoderConfig(EncoderConfig encoderConfig) voidsetMinCompressSize(int minCompressSize) stripSuffixes(String etagsList) Strip this compression suffix 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, updateBeansMethods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, setEventListeners, start, stop, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.jetty.util.component.Container
getCachedBeans, getEventListenersMethods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpable
-
Constructor Details
-
Compression
-
-
Method Details
-
acquireByteBuffer
Acquire aRetainableByteBufferthat is managed by thisCompressionimplementation which is suitable for compressed output from anEncoderSinkor 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
Get an etag with suffix that represents this compression implementation.- Parameters:
etag- an etag- Returns:
- the etag with compression suffix
-
getBufferSize
Deprecated, for removal: This API element is subject to removal in a future version.useEncoderConfig.getBufferSize()orDecoderConfig.getBufferSize()instead.This always returns 0. -
setBufferSize
Deprecated, for removal: This API element is subject to removal in a future version.useEncoderConfig.setBufferSize(int)orDecoderConfig.setBufferSize(int)instead.This has no effect. -
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
TheHttpFieldforContent-Encodingsuitable for this Compression implementation.- Returns:
- the HttpField for
Content-Encoding.
-
getDefaultDecoderConfig
-
setDefaultDecoderConfig
-
getDefaultEncoderConfig
-
setDefaultEncoderConfig
-
getEncodingName
The name of the encoding if seen in the HTTP protocol in fields likeContent-EncodingorAccept-Encoding. This name is also reused for theETagrepresentations of the compressed content.- Returns:
- the name of the Content-Encoding for this compression implementation.
-
getEtagSuffix
Get the ETag suffix.- Returns:
- the etag suffix for this compression.
-
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
TheHttpFieldforX-Content-Encodingsuitable for this Compression implementation.- Returns:
- the HttpField for
X-Content-Encoding.
-
newDecoderInputStream
Create a newInputStreamto decode (decompress) with this compression implementation.- Parameters:
in- the input stream to write the decoded (decompressed) bytes to- Returns:
- the
InputStreamimplementation for this compression. - Throws:
IOException- if unable to create InputStream
-
newDecoderInputStream
public abstract InputStream newDecoderInputStream(InputStream in, DecoderConfig config) throws IOException Create a newInputStreamto decode (decompress) with this compression implementation.- Parameters:
in- the input stream to write the decoded (decompressed) bytes toconfig- theDecoderConfigfor this input stream.- Returns:
- the
InputStreamimplementation for this compression. - Throws:
IOException- if unable to create InputStream
-
newDecoderSource
Create a newDecoderSourcefor this compression implementation- Parameters:
source- the source to write the decoded bytes to- Returns:
- a new
DecoderSource
-
newDecoderSource
Create a newDecoderSourcefor this compression implementation- Parameters:
source- the source to write the decoded bytes toconfig- theDecoderConfigfor this source.- Returns:
- a new
DecoderSource
-
newEncoderOutputStream
Create a newOutputStreamto encode (compress) with this compression implementation.- Parameters:
out- the output stream to write the encoded (compressed) bytes to- Returns:
- the
OutputStreamimplementation for this compression. - Throws:
IOException- if unable to create OutputStream
-
newEncoderOutputStream
public abstract OutputStream newEncoderOutputStream(OutputStream out, EncoderConfig config) throws IOException Create a newOutputStreamto encode (compress) with this compression implementation.- Parameters:
out- the output stream to write the encoded (compressed) bytes toconfig- theEncoderConfigfor this output stream.- Returns:
- the
OutputStreamimplementation for this compression. - Throws:
IOException- if unable to create OutputStream
-
newEncoderSink
Create a newEncoderSinkfor this compression implementation- Parameters:
sink- the sink to write the encoded bytes to- Returns:
- a new
EncoderSink
-
newEncoderSink
Create a newEncoderSinkfor this compression implementation- Parameters:
sink- the sink to write the encoded bytes toconfig- theEncoderConfigfor this sink.- Returns:
- a new
EncoderSink
-
stripSuffixes
Strip this compression suffix off etags- Parameters:
etagsList- the list of etags to strip- Returns:
- the tags stripped of compression suffixes.
-
doStart
Description copied from class:ContainerLifeCycleStarts the managed lifecycle beans in the order they were added.- Overrides:
doStartin classContainerLifeCycle- Throws:
AbstractLifeCycle.StopException- If thrown, the lifecycle will immediately be stopped.Exception- If there was a problem starting. Will cause a transition to FAILED state
-
EncoderConfig.getBufferSize()orDecoderConfig.getBufferSize()instead.