| Modifier and Type | Class and Description |
|---|---|
| private static class | BrotliEncoder.
|
| Modifier and Type | Field and Description |
|---|---|
| private static final AttributeKey | |
| private final boolean | |
| private final Encoder. | |
| private BrotliEncoder. |
| Access | Constructor and Description |
|---|---|
| public | BrotliEncoder()
Create a new |
| public | |
| public | BrotliEncoder(Encoder.
Encoder. to useCreate a new |
| public | BrotliEncoder(Encoder.
Encoder. to useSet to isSharable)true if this instance is shared else set to false
Create a new |
| Modifier and Type | Method and Description |
|---|---|
| protected ByteBuf | allocateBuffer(ChannelHandlerContext ctx, ByteBuf msg, boolean preferDirect)
Overrides io. ByteBuf which will be used as argument of encode(ChannelHandlerContext, I, ByteBuf).
|
| public void | close(final ChannelHandlerContext
the ctx, final ChannelPromise ChannelHandlerContext for which the close operation is madethe promise)ChannelPromise to notify once the operation completesOverrides io. Implements io. ChannelHandlerContext#close(ChannelPromise) to forward
to the next ChannelOutboundHandler in the ChannelPipeline.
|
| protected void | encode(ChannelHandlerContext
the ctx, ByteBuf ChannelHandlerContext which this MessageToByteEncoder belongs tothe message to encode msg, ByteBuf the out)ByteBuf into which the encoded message will be writtenImplements abstract io. ByteBuf.
|
| public void | finish(ChannelHandlerContext
ChannelHandlerContext which we want to closeFinish the encoding, close streams and write final |
| private ChannelFuture | |
| public void | handlerAdded(ChannelHandlerContext ctx)
Overrides io. Implements io. ChannelHandler was added to the actual context and it's ready to handle events.
|
| public void | handlerRemoved(ChannelHandlerContext ctx)
Overrides io. Implements io. ChannelHandler was removed from the actual context and it doesn't handle events
anymore.
|
| public boolean | isSharable()
Overrides io. true if the implementation is Sharable and so can be added
to different ChannelPipelines.
|
| ATTR | back to summary |
|---|---|
| private static final AttributeKey<BrotliEncoder. | |
| isSharable | back to summary |
|---|---|
| private final boolean isSharable | |
| parameters | back to summary |
|---|---|
| private final Encoder. | |
| writer | back to summary |
|---|---|
| private BrotliEncoder. | |
| BrotliEncoder | back to summary |
|---|---|
| public BrotliEncoder() Create a new | |
| BrotliEncoder | back to summary |
|---|---|
| public BrotliEncoder(BrotliOptions brotliOptions) Create a new
| |
| BrotliEncoder | back to summary |
|---|---|
| public BrotliEncoder(Encoder. Create a new
| |
| BrotliEncoder | back to summary |
|---|---|
| public BrotliEncoder(Encoder.
Create a new isSharable() is true then on handlerAdded(ChannelHandlerContext) call,
a new Writer will create, and it will be mapped using Channel#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.
| |
| allocateBuffer | back to summary |
|---|---|
| protected ByteBuf allocateBuffer(ChannelHandlerContext ctx, ByteBuf msg, boolean preferDirect) throws Exception Overrides io. Doc from io. Allocate a
| |
| close | back to summary |
|---|---|
| public void close(final ChannelHandlerContext ctx, final ChannelPromise promise) throws Exception Overrides io. Implements io. Doc from io. Calls
| |
| encode | back to summary |
|---|---|
| protected void encode(ChannelHandlerContext ctx, ByteBuf msg, ByteBuf out) throws Exception Implements abstract io. Doc from io. Encode a message into a
| |
| finish | back to summary |
|---|---|
| public void finish(ChannelHandlerContext ctx) throws IOException Finish the encoding, close streams and write final
| |
| finishEncode | back to summary |
|---|---|
| private ChannelFuture finishEncode(ChannelHandlerContext ctx, ChannelPromise promise) throws IOException | |
| handlerAdded | back to summary |
|---|---|
| public void handlerAdded(ChannelHandlerContext ctx) throws Exception Overrides io. Implements io. Doc from io. Gets called after the
| |
| handlerRemoved | back to summary |
|---|---|
| public void handlerRemoved(ChannelHandlerContext ctx) throws Exception Overrides io. Implements io. Doc from io. Gets called after the
| |
| isSharable | back to summary |
|---|---|
| public boolean isSharable() Overrides io. Doc from io. Return
| |
Writer is the implementation of WritableByteChannel which encodes
Brotli data and stores it into ByteBuf.
| Modifier and Type | Field and Description |
|---|---|
| private final BrotliEncoderChannel | |
| private final ChannelHandlerContext | |
| private boolean | |
| private ByteBuf |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| public void | |
| private void | |
| public void | |
| public boolean | |
| public int | write(ByteBuffer
The buffer from which bytes are to be retrieved src)Implements java. |
| brotliEncoderChannel | back to summary |
|---|---|
| private final BrotliEncoderChannel brotliEncoderChannel | |
| ctx | back to summary |
|---|---|
| private final ChannelHandlerContext ctx | |
| isClosed | back to summary |
|---|---|
| private boolean isClosed | |
| writableBuffer | back to summary |
|---|---|
| private ByteBuf writableBuffer | |
| Writer | back to summary |
|---|---|
| private Writer(Encoder. | |
| allocate | back to summary |
|---|---|
| private void allocate(boolean preferDirect) | |
| close | back to summary |
|---|---|
| public void close() Implements java. Doc from java. Closes this channel. After a channel is closed, any further attempt to invoke I/O
operations upon it will cause a If this channel is already closed then invoking this method has no effect. This method may be invoked at any time. If some other thread has already invoked it, however, then another invocation will block until the first invocation is complete, after which it will return without effect.
| |
| encode | back to summary |
|---|---|
| private void encode(ByteBuf msg, boolean preferDirect) throws Exception | |
| finish | back to summary |
|---|---|
| public void finish(final ChannelPromise promise) throws IOException | |
| isOpen | back to summary |
|---|---|
| public boolean isOpen() Implements java. Doc from java. Tells whether or not this channel is open.
| |
| write | back to summary |
|---|---|
| public int write(ByteBuffer src) throws IOException Implements java. Doc from java. Writes a sequence of bytes to this channel from the given buffer. An attempt is made to write up to r bytes to the channel,
where r is the number of bytes remaining in the buffer, that is,
Suppose that a byte sequence of length n is written, where
Unless otherwise specified, a write operation will return only after writing all of the r requested bytes. Some types of channels, depending upon their state, may write only some of the bytes or possibly none at all. A socket channel in non-blocking mode, for example, cannot write any more bytes than are free in the socket's output buffer. This method may be invoked at any time. If another thread has already initiated a write operation upon this channel, however, then an invocation of this method will block until the first operation is complete.
| |