@ChannelHandler.Sharable
public final class BrotliEncoder
extends io.netty.handler.codec.MessageToByteEncoder<io.netty.buffer.ByteBuf>
ByteBuf with the Brotli compression.
See brotli.
| Constructor and Description |
|---|
BrotliEncoder()
|
BrotliEncoder(BrotliOptions brotliOptions)
Create a new
BrotliEncoder Instance |
BrotliEncoder(com.aayushatharva.brotli4j.encoder.Encoder.Parameters parameters)
|
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. |
| Modifier and Type | Method and Description |
|---|---|
protected io.netty.buffer.ByteBuf |
allocateBuffer(io.netty.channel.ChannelHandlerContext ctx,
io.netty.buffer.ByteBuf msg,
boolean preferDirect) |
void |
close(io.netty.channel.ChannelHandlerContext ctx,
io.netty.channel.ChannelPromise promise) |
protected void |
encode(io.netty.channel.ChannelHandlerContext ctx,
io.netty.buffer.ByteBuf msg,
io.netty.buffer.ByteBuf out) |
void |
finish(io.netty.channel.ChannelHandlerContext ctx)
Finish the encoding, close streams and write final
ByteBuf to the channel. |
void |
handlerAdded(io.netty.channel.ChannelHandlerContext ctx) |
void |
handlerRemoved(io.netty.channel.ChannelHandlerContext ctx) |
boolean |
isSharable() |
acceptOutboundMessage, isPreferDirect, writebind, connect, deregister, disconnect, flush, readensureNotSharable, exceptionCaughtpublic BrotliEncoder()
public BrotliEncoder(BrotliOptions brotliOptions)
BrotliEncoder InstancebrotliOptions - BrotliOptions to use and
isSharable() set to truepublic BrotliEncoder(com.aayushatharva.brotli4j.encoder.Encoder.Parameters parameters)
parameters - Encoder.Parameters to usepublic 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.
isSharable() is true then on handlerAdded(ChannelHandlerContext) call,
a new 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 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 - Encoder.Parameters to useisSharable - Set to true if this instance is shared else set to falsepublic void handlerAdded(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
handlerAdded in interface io.netty.channel.ChannelHandlerhandlerAdded in class io.netty.channel.ChannelHandlerAdapterExceptionpublic void handlerRemoved(io.netty.channel.ChannelHandlerContext ctx)
throws Exception
handlerRemoved in interface io.netty.channel.ChannelHandlerhandlerRemoved in class io.netty.channel.ChannelHandlerAdapterExceptionprotected void encode(io.netty.channel.ChannelHandlerContext ctx,
io.netty.buffer.ByteBuf msg,
io.netty.buffer.ByteBuf out)
throws Exception
encode in class io.netty.handler.codec.MessageToByteEncoder<io.netty.buffer.ByteBuf>Exceptionprotected io.netty.buffer.ByteBuf allocateBuffer(io.netty.channel.ChannelHandlerContext ctx,
io.netty.buffer.ByteBuf msg,
boolean preferDirect)
throws Exception
allocateBuffer in class io.netty.handler.codec.MessageToByteEncoder<io.netty.buffer.ByteBuf>Exceptionpublic boolean isSharable()
isSharable in class io.netty.channel.ChannelHandlerAdapterpublic void finish(io.netty.channel.ChannelHandlerContext ctx)
throws IOException
ByteBuf to the channel.ctx - ChannelHandlerContext which we want to closeIOException - If an error occurred during closureCopyright © 2008–2024 The Netty Project. All rights reserved.