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:
org.eclipse.jetty.util.component.Container, org.eclipse.jetty.util.component.Destroyable, org.eclipse.jetty.util.component.Dumpable, org.eclipse.jetty.util.component.Dumpable.DumpableContainer, org.eclipse.jetty.util.component.LifeCycle

public abstract class Compression extends org.eclipse.jetty.util.component.ContainerLifeCycle
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

    org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener, org.eclipse.jetty.util.component.AbstractLifeCycle.StopException

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container

    org.eclipse.jetty.util.component.Container.InheritedListener, org.eclipse.jetty.util.component.Container.Listener

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable

    org.eclipse.jetty.util.component.Dumpable.DumpableContainer, org.eclipse.jetty.util.component.Dumpable.DumpAppendable

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle

    org.eclipse.jetty.util.component.LifeCycle.Listener
  • Field Summary

    Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

    FAILED, STARTED, STARTING, STOPPED, STOPPING

    Fields inherited from interface org.eclipse.jetty.util.component.Dumpable

    LEGEND
  • Constructor Summary

    Constructors
    Constructor
    Description
    Compression(String encoding)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract org.eclipse.jetty.io.RetainableByteBuffer.Mutable
    acquireByteBuffer(int length)
    Acquire a RetainableByteBuffer that is managed by this Compression implementation which is suitable for compressed output from an EncoderSink or compressed input from a DecoderSource.
    protected void
     
    etag(String etag)
    Get an etag with suffix that represents this compression implementation.
    int
    Deprecated, for removal: This API element is subject to removal in a future version.
    org.eclipse.jetty.io.ByteBufferPool
     
    org.eclipse.jetty.util.component.Container
    Get the container being used for common components.
    abstract org.eclipse.jetty.http.HttpField
    The HttpField for Content-Encoding suitable for this Compression implementation.
    abstract DecoderConfig
     
    abstract EncoderConfig
     
    The name of the encoding if seen in the HTTP protocol in fields like Content-Encoding or Accept-Encoding.
    Get the ETag suffix.
    abstract List<String>
    The filename extensions for this compression implementation.
    int
     
    abstract String
     
    abstract org.eclipse.jetty.http.HttpField
    The HttpField for X-Content-Encoding suitable for this Compression implementation.
    Create a new InputStream to decode (decompress) with this compression implementation.
    abstract InputStream
    Create a new InputStream to decode (decompress) with this compression implementation.
    newDecoderSource(org.eclipse.jetty.io.Content.Source source)
    Create a new DecoderSource for this compression implementation
    abstract DecoderSource
    newDecoderSource(org.eclipse.jetty.io.Content.Source source, DecoderConfig config)
    Create a new DecoderSource for this compression implementation
    Create a new OutputStream to encode (compress) with this compression implementation.
    abstract OutputStream
    Create a new OutputStream to encode (compress) with this compression implementation.
    newEncoderSink(org.eclipse.jetty.io.Content.Sink sink)
    Create a new EncoderSink for this compression implementation
    abstract EncoderSink
    newEncoderSink(org.eclipse.jetty.io.Content.Sink sink, EncoderConfig config)
    Create a new EncoderSink for this compression implementation
    void
    setBufferSize(int size)
    Deprecated, for removal: This API element is subject to removal in a future version.
    void
    setByteBufferPool(org.eclipse.jetty.io.ByteBufferPool byteBufferPool)
     
    void
    setContainer(org.eclipse.jetty.util.component.Container container)
    Set the container that this compression implementation should use.
    abstract void
     
    abstract void
     
    void
    setMinCompressSize(int minCompressSize)
     
    stripSuffixes(String etagsList)
    Strip this compression suffix off etags

    Methods 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 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

    dumpSelf

    Methods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer

    isDumpable
  • Constructor Details

    • Compression

      public Compression(String encoding)
  • Method Details

    • acquireByteBuffer

      public abstract org.eclipse.jetty.io.RetainableByteBuffer.Mutable acquireByteBuffer(int length)
      Acquire a RetainableByteBuffer that is managed by this Compression implementation which is suitable for compressed output from an EncoderSink or compressed input from a DecoderSource.

      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

      public String etag(String etag)
      Get an etag with suffix that represents this compression implementation.
      Parameters:
      etag - an etag
      Returns:
      the etag with compression suffix
    • getBufferSize

      @Deprecated(forRemoval=true, since="12.1.5") public int getBufferSize()
      Deprecated, for removal: This API element is subject to removal in a future version.
      This always returns 0.
    • setBufferSize

      @Deprecated(forRemoval=true, since="12.1.5") public void setBufferSize(int size)
      Deprecated, for removal: This API element is subject to removal in a future version.
      This has no effect.
    • getByteBufferPool

      public org.eclipse.jetty.io.ByteBufferPool getByteBufferPool()
    • setByteBufferPool

      public void setByteBufferPool(org.eclipse.jetty.io.ByteBufferPool byteBufferPool)
    • getContainer

      public org.eclipse.jetty.util.component.Container getContainer()
      Get the container being used for common components.
      Returns:
      the container for common components
    • setContainer

      public void setContainer(org.eclipse.jetty.util.component.Container container)
      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

      public abstract org.eclipse.jetty.http.HttpField getContentEncodingField()
      The HttpField for Content-Encoding suitable for this Compression implementation.
      Returns:
      the HttpField for Content-Encoding.
    • getDefaultDecoderConfig

      public abstract DecoderConfig getDefaultDecoderConfig()
    • setDefaultDecoderConfig

      public abstract void setDefaultDecoderConfig(DecoderConfig decoderConfig)
    • getDefaultEncoderConfig

      public abstract EncoderConfig getDefaultEncoderConfig()
    • setDefaultEncoderConfig

      public abstract void setDefaultEncoderConfig(EncoderConfig encoderConfig)
    • getEncodingName

      public String getEncodingName()
      The name of the encoding if seen in the HTTP protocol in fields like Content-Encoding or Accept-Encoding. This name is also reused for the ETag representations of the compressed content.
      Returns:
      the name of the Content-Encoding for this compression implementation.
    • getEtagSuffix

      public String getEtagSuffix()
      Get the ETag suffix.
      Returns:
      the etag suffix for this compression.
    • getFileExtensionNames

      public abstract List<String> 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

      public abstract String getName()
      Returns:
      the name of the compression implementation.
    • getXContentEncodingField

      public abstract org.eclipse.jetty.http.HttpField getXContentEncodingField()
      The HttpField for X-Content-Encoding suitable for this Compression implementation.
      Returns:
      the HttpField for X-Content-Encoding.
    • newDecoderInputStream

      public InputStream newDecoderInputStream(InputStream in) throws IOException
      Create a new InputStream 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 new InputStream to decode (decompress) with this compression implementation.
      Parameters:
      in - the input stream to write the decoded (decompressed) bytes to
      config - the DecoderConfig for this input stream.
      Returns:
      the InputStream implementation for this compression.
      Throws:
      IOException - if unable to create InputStream
    • newDecoderSource

      public DecoderSource newDecoderSource(org.eclipse.jetty.io.Content.Source source)
      Create a new DecoderSource for this compression implementation
      Parameters:
      source - the source to write the decoded bytes to
      Returns:
      a new DecoderSource
    • newDecoderSource

      public abstract DecoderSource newDecoderSource(org.eclipse.jetty.io.Content.Source source, DecoderConfig config)
      Create a new DecoderSource for this compression implementation
      Parameters:
      source - the source to write the decoded bytes to
      config - the DecoderConfig for this source.
      Returns:
      a new DecoderSource
    • newEncoderOutputStream

      public OutputStream newEncoderOutputStream(OutputStream out) throws IOException
      Create a new OutputStream 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 new OutputStream to encode (compress) with this compression implementation.
      Parameters:
      out - the output stream to write the encoded (compressed) bytes to
      config - the EncoderConfig for this output stream.
      Returns:
      the OutputStream implementation for this compression.
      Throws:
      IOException - if unable to create OutputStream
    • newEncoderSink

      public EncoderSink newEncoderSink(org.eclipse.jetty.io.Content.Sink sink)
      Create a new EncoderSink for this compression implementation
      Parameters:
      sink - the sink to write the encoded bytes to
      Returns:
      a new EncoderSink
    • newEncoderSink

      public abstract EncoderSink newEncoderSink(org.eclipse.jetty.io.Content.Sink sink, EncoderConfig config)
      Create a new EncoderSink for this compression implementation
      Parameters:
      sink - the sink to write the encoded bytes to
      config - the EncoderConfig for this sink.
      Returns:
      a new EncoderSink
    • stripSuffixes

      public String stripSuffixes(String etagsList)
      Strip this compression suffix off etags
      Parameters:
      etagsList - the list of etags to strip
      Returns:
      the tags stripped of compression suffixes.
    • doStart

      protected void doStart() throws Exception
      Overrides:
      doStart in class org.eclipse.jetty.util.component.ContainerLifeCycle
      Throws:
      Exception