Top Description Fields Constructors Methods
io.netty5.handler.codec.compression

public final Class CompressionHandler

extends Object
implements ChannelHandler
Class Inheritance
All Implemented Interfaces
io.netty5.channel.ChannelHandler
Imports
io.netty5.buffer.Buffer, io.netty5.channel.ChannelHandler, .ChannelHandlerContext, io.netty5.util.concurrent.Future, .Promise, java.util.concurrent.TimeUnit, java.util.function.Supplier

ChannelHandler which uses a Compressor for compressing the written Buffers.

Field Summary

Modifier and TypeField and Description
private final long
private final TimeUnit
private Compressor
private final Supplier<? extends Compressor>
private final boolean

Constructor Summary

AccessConstructor and Description
public
CompressionHandler(Supplier<? extends Compressor>
the Supplier that is used to create the Compressor.
compressorSupplier
)

Creates a new instance.

public
CompressionHandler(Supplier<? extends Compressor>
the Supplier that is used to create the Compressor.
compressorSupplier
,
long
the amount to wait before we will close even tho the write of the trailer was not finished yet.
closeWriteTimeout
,
TimeUnit
the unit of the timeout.
closeWriteTimeoutUnit
,
boolean
true if the bytes should be discarded after the Compressor finished the compression of the whole stream.
discardBytesAfterFinished
)

Creates a new instance.

Method Summary

Modifier and TypeMethod and Description
public void
channelInactive(ChannelHandlerContext ctx)

Overrides default io.netty5.channel.ChannelHandler.channelInactive.

The Channel of the ChannelHandlerContext was registered is now inactive and reached its end of lifetime.
public Future<Void>
close(ChannelHandlerContext
the ChannelHandlerContext for which the close operation is made
ctx
)

Overrides default io.netty5.channel.ChannelHandler.close.

Called once a close operation is made.
private void
private Future<Void>
finish(ChannelHandlerContext ctx, boolean closeCtx)

public void
handlerAdded(ChannelHandlerContext ctx)

Overrides default io.netty5.channel.ChannelHandler.handlerAdded.

Gets called after the ChannelHandler was added to the actual context and it's ready to handle events.
public void
handlerRemoved(ChannelHandlerContext ctx)

Overrides default io.netty5.channel.ChannelHandler.handlerRemoved.

Gets called after the ChannelHandler was removed from the actual context and it doesn't handle events anymore.
public Future<Void>
write(ChannelHandlerContext
the ChannelHandlerContext for which the write operation is made
ctx
,
Object
the message to write
msg
)

Overrides default io.netty5.channel.ChannelHandler.write.

Called once a write operation is made.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

closeWriteTimeoutback to summary
private final long closeWriteTimeout
closeWriteTimeoutUnitback to summary
private final TimeUnit closeWriteTimeoutUnit
compressorback to summary
private Compressor compressor
compressorSupplierback to summary
private final Supplier<? extends Compressor> compressorSupplier
discardBytesAfterFinishedback to summary
private final boolean discardBytesAfterFinished

Constructor Detail

CompressionHandlerback to summary
public CompressionHandler(Supplier<? extends Compressor> compressorSupplier)

Creates a new instance.

Parameters
compressorSupplier:Supplier<? extends Compressor>

the Supplier that is used to create the Compressor.

CompressionHandlerback to summary
public CompressionHandler(Supplier<? extends Compressor> compressorSupplier, long closeWriteTimeout, TimeUnit closeWriteTimeoutUnit, boolean discardBytesAfterFinished)

Creates a new instance.

Parameters
compressorSupplier:Supplier<? extends Compressor>

the Supplier that is used to create the Compressor.

closeWriteTimeout:long

the amount to wait before we will close even tho the write of the trailer was not finished yet.

closeWriteTimeoutUnit:TimeUnit

the unit of the timeout.

discardBytesAfterFinished:boolean

true if the bytes should be discarded after the Compressor finished the compression of the whole stream.

Method Detail

channelInactiveback to summary
public void channelInactive(ChannelHandlerContext ctx) throws Exception

Overrides default io.netty5.channel.ChannelHandler.channelInactive.

Doc from io.netty5.channel.ChannelHandler.channelInactive.

The Channel of the ChannelHandlerContext was registered is now inactive and reached its end of lifetime.

Annotations
@Override
closeback to summary
public Future<Void> close(ChannelHandlerContext ctx)

Overrides default io.netty5.channel.ChannelHandler.close.

Doc from io.netty5.channel.ChannelHandler.close.

Called once a close operation is made.

Parameters
ctx:ChannelHandlerContext

the ChannelHandlerContext for which the close operation is made

Returns:Future<Void>

the Future which will be notified once the operation completes.

Annotations
@Override
closeCompressorback to summary
private void closeCompressor()
finishback to summary
private Future<Void> finish(ChannelHandlerContext ctx, boolean closeCtx)
handlerAddedback to summary
public void handlerAdded(ChannelHandlerContext ctx) throws Exception

Overrides default io.netty5.channel.ChannelHandler.handlerAdded.

Doc from io.netty5.channel.ChannelHandler.handlerAdded.

Gets called after the ChannelHandler was added to the actual context and it's ready to handle events.

Annotations
@Override
handlerRemovedback to summary
public void handlerRemoved(ChannelHandlerContext ctx) throws Exception

Overrides default io.netty5.channel.ChannelHandler.handlerRemoved.

Doc from io.netty5.channel.ChannelHandler.handlerRemoved.

Gets called after the ChannelHandler was removed from the actual context and it doesn't handle events anymore.

Annotations
@Override
writeback to summary
public Future<Void> write(ChannelHandlerContext ctx, Object msg)

Overrides default io.netty5.channel.ChannelHandler.write.

Doc from io.netty5.channel.ChannelHandler.write.

Called once a write operation is made. The write operation will write the messages through the ChannelPipeline. Those are then ready to be flushed to the actual Channel once Channel#flush() is called.

Parameters
ctx:ChannelHandlerContext

the ChannelHandlerContext for which the write operation is made

msg:Object

the message to write

Returns:Future<Void>

the Future which will be notified once the operation completes.

Annotations
@Override