GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Overview
  • Use
  • Tree
  • Deprecated
  • Index
  • Search
  • Help
  • io.netty.handler.codec.compression
  • BrotliEncoder

This view

  • Original page
  • New address

GeezerVison is showing netty.io — BrotliEncoder (Netty API Reference (4.1.141.Final))

Class BrotliEncoder

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelOutboundHandlerAdapter
io.netty.handler.codec.MessageToByteEncoder<ByteBuf>
io.netty.handler.codec.compression.BrotliEncoder
All Implemented Interfaces:
ChannelHandler, ChannelOutboundHandler

@Sharable public final class BrotliEncoder extends MessageToByteEncoder<ByteBuf>
Compress a ByteBuf with the Brotli compression.

See brotli.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface ChannelHandler

    ChannelHandler.Sharable
    Modifier and Type
    Interface
    Description
    static @interface 
    ChannelHandler.Sharable
    Indicates that the same instance of the annotated ChannelHandler can be added to one or more ChannelPipelines multiple times without a race condition.
  • Constructor Summary

    Constructors
    Constructor
    Description
    BrotliEncoder()
    Create a new BrotliEncoder Instance with BrotliOptions.DEFAULT and isSharable() set to true
    BrotliEncoder(com.aayushatharva.brotli4j.encoder.Encoder.Parameters parameters)
    Create a new BrotliEncoder Instance and isSharable() set to true
    BrotliEncoder(com.aayushatharva.brotli4j.encoder.Encoder.Parameters parameters, boolean isSharable)
    Create a new BrotliEncoder Instance and specify whether this instance will be shared with multiple pipelines or not.
    BrotliEncoder(BrotliOptions brotliOptions)
    Create a new BrotliEncoder Instance
  • Method Summary

    Modifier and Type
    Method
    Description
    protected ByteBuf
    allocateBuffer(ChannelHandlerContext ctx, ByteBuf msg, boolean preferDirect)
    Allocate a ByteBuf which will be used as argument of MessageToByteEncoder.encode(ChannelHandlerContext, I, ByteBuf).
    void
    close(ChannelHandlerContext ctx, ChannelPromise promise)
    Calls ChannelOutboundInvoker.close(ChannelPromise) to forward to the next ChannelOutboundHandler in the ChannelPipeline.
    protected void
    encode(ChannelHandlerContext ctx, ByteBuf msg, ByteBuf out)
    Encode a message into a ByteBuf.
    void
    finish(ChannelHandlerContext ctx)
    Finish the encoding, close streams and write final ByteBuf to the channel.
    void
    handlerAdded(ChannelHandlerContext ctx)
    Do nothing by default, sub-classes may override this method.
    void
    handlerRemoved(ChannelHandlerContext ctx)
    Do nothing by default, sub-classes may override this method.
    boolean
    isSharable()
    Return true if the implementation is ChannelHandler.Sharable and so can be added to different ChannelPipelines.

    Methods inherited from class MessageToByteEncoder

    acceptOutboundMessage, isPreferDirect, write
    Modifier and Type
    Method
    Description
    boolean
    acceptOutboundMessage(Object msg)
    Returns true if the given message should be handled.
    protected boolean
    isPreferDirect()
     
    void
    write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
    Calls ChannelOutboundInvoker.write(Object, ChannelPromise) to forward to the next ChannelOutboundHandler in the ChannelPipeline.

    Methods inherited from class ChannelOutboundHandlerAdapter

    bind, connect, deregister, disconnect, flush, read
    Modifier and Type
    Method
    Description
    void
    bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise)
    Calls ChannelOutboundInvoker.bind(SocketAddress, ChannelPromise) to forward to the next ChannelOutboundHandler in the ChannelPipeline.
    void
    connect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise)
    Calls ChannelOutboundInvoker.connect(SocketAddress, SocketAddress, ChannelPromise) to forward to the next ChannelOutboundHandler in the ChannelPipeline.
    void
    deregister(ChannelHandlerContext ctx, ChannelPromise promise)
    Calls ChannelOutboundInvoker.deregister(ChannelPromise) to forward to the next ChannelOutboundHandler in the ChannelPipeline.
    void
    disconnect(ChannelHandlerContext ctx, ChannelPromise promise)
    Calls ChannelOutboundInvoker.disconnect(ChannelPromise) to forward to the next ChannelOutboundHandler in the ChannelPipeline.
    void
    flush(ChannelHandlerContext ctx)
    Calls ChannelHandlerContext.flush() to forward to the next ChannelOutboundHandler in the ChannelPipeline.
    void
    read(ChannelHandlerContext ctx)
    Calls ChannelHandlerContext.read() to forward to the next ChannelOutboundHandler in the ChannelPipeline.

    Methods inherited from class ChannelHandlerAdapter

    ensureNotSharable, exceptionCaught
    Modifier and Type
    Method
    Description
    protected void
    ensureNotSharable()
    Throws IllegalStateException if ChannelHandlerAdapter.isSharable() returns true
    void
    exceptionCaught(ChannelHandlerContext ctx, Throwable cause)
    Deprecated.
    is part of ChannelInboundHandler

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • BrotliEncoder

      public BrotliEncoder()
      Create a new BrotliEncoder Instance with BrotliOptions.DEFAULT and isSharable() set to true
    • BrotliEncoder

      public BrotliEncoder(BrotliOptions brotliOptions)
      Create a new BrotliEncoder Instance
      Parameters:
      brotliOptions - BrotliOptions to use and isSharable() set to true
    • BrotliEncoder

      public BrotliEncoder(com.aayushatharva.brotli4j.encoder.Encoder.Parameters parameters)
      Create a new BrotliEncoder Instance and isSharable() set to true
      Parameters:
      parameters - Encoder.Parameters to use
    • BrotliEncoder

      public BrotliEncoder(com.aayushatharva.brotli4j.encoder.Encoder.Parameters parameters, boolean isSharable)

      Create a new BrotliEncoder Instance and specify whether this instance will be shared with multiple pipelines or not.

      If isSharable() is true then on handlerAdded(ChannelHandlerContext) call, a new BrotliEncoder.Writer will create, and it will be mapped using AttributeMap.attr(AttributeKey) so BrotliEncoder can be shared with multiple pipelines. This works fine but there on every encode(ChannelHandlerContext, ByteBuf, ByteBuf) call, we have to get the BrotliEncoder.Writer associated with the appropriate channel. And this will add a overhead. So it is recommended to set isSharable() to false and create new BrotliEncoder instance for every pipeline.
      Parameters:
      parameters - Encoder.Parameters to use
      isSharable - Set to true if this instance is shared else set to false
  • Method Details

    • handlerAdded

      public void handlerAdded(ChannelHandlerContext ctx) throws Exception
      Description copied from class: ChannelHandlerAdapter
      Do nothing by default, sub-classes may override this method.
      Specified by:
      handlerAdded in interface ChannelHandler
      Overrides:
      handlerAdded in class ChannelHandlerAdapter
      Throws:
      Exception
    • handlerRemoved

      public void handlerRemoved(ChannelHandlerContext ctx) throws Exception
      Description copied from class: ChannelHandlerAdapter
      Do nothing by default, sub-classes may override this method.
      Specified by:
      handlerRemoved in interface ChannelHandler
      Overrides:
      handlerRemoved in class ChannelHandlerAdapter
      Throws:
      Exception
    • encode

      protected void encode(ChannelHandlerContext ctx, ByteBuf msg, ByteBuf out) throws Exception
      Description copied from class: MessageToByteEncoder
      Encode a message into a ByteBuf. This method will be called for each written message that can be handled by this encoder.
      Specified by:
      encode in class MessageToByteEncoder<ByteBuf>
      Parameters:
      ctx - the ChannelHandlerContext which this MessageToByteEncoder belongs to
      msg - the message to encode
      out - the ByteBuf into which the encoded message will be written
      Throws:
      Exception - is thrown if an error occurs
    • allocateBuffer

      protected ByteBuf allocateBuffer(ChannelHandlerContext ctx, ByteBuf msg, boolean preferDirect) throws Exception
      Description copied from class: MessageToByteEncoder
      Allocate a ByteBuf which will be used as argument of MessageToByteEncoder.encode(ChannelHandlerContext, I, ByteBuf). Sub-classes may override this method to return ByteBuf with a perfect matching initialCapacity.
      Overrides:
      allocateBuffer in class MessageToByteEncoder<ByteBuf>
      Throws:
      Exception
    • isSharable

      public boolean isSharable()
      Description copied from class: ChannelHandlerAdapter
      Return true if the implementation is ChannelHandler.Sharable and so can be added to different ChannelPipelines.
      Overrides:
      isSharable in class ChannelHandlerAdapter
    • finish

      public void finish(ChannelHandlerContext ctx) throws IOException
      Finish the encoding, close streams and write final ByteBuf to the channel.
      Parameters:
      ctx - ChannelHandlerContext which we want to close
      Throws:
      IOException - If an error occurred during closure
    • close

      public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception
      Description copied from class: ChannelOutboundHandlerAdapter
      Calls ChannelOutboundInvoker.close(ChannelPromise) to forward to the next ChannelOutboundHandler in the ChannelPipeline. Sub-classes may override this method to change behavior.
      Specified by:
      close in interface ChannelOutboundHandler
      Overrides:
      close in class ChannelOutboundHandlerAdapter
      Parameters:
      ctx - the ChannelHandlerContext for which the close operation is made
      promise - the ChannelPromise to notify once the operation completes
      Throws:
      Exception - thrown if an error occurs
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.