org.apache.mina.filter
Class CompressionFilter
- IoFilter
public class CompressionFilter
An
IoFilter
which compresses all data using
JZlib.
Support for the LZW (DLCZ) algorithm is also planned.
This filter only supports compression using the
PARTIAL FLUSH method,
since that is the only method useful when doing stream level compression.
This filter supports compression/decompression of the input and output
channels selectively. It can also be enabled/disabled on the fly.
This filter does not discard the zlib objects, keeping them around for the
entire life of the filter. This is because the zlib dictionary needs to
be built up over time, which is used during compression and decompression.
Over time, as repetitive data is sent over the wire, the compression efficiency
steadily increases.
Note that the zlib header is written only once. It is not necessary that
the data received after processing by this filter may not be complete due
to packet fragmentation.
It goes without saying that the other end of this stream should also have a
compatible compressor/decompressor using the same algorithm.
CompressionFilter() - Creates a new instance which compresses outboud data and decompresses
inbound data with default compression level.
|
CompressionFilter(boolean compressInbound, boolean compressOutbound, int compressionLevel) - Creates a new instance.
|
CompressionFilter(int compressionLevel) - Creates a new instance which compresses outboud data and decompresses
inbound data with the specified compressionLevel.
|
destroy , exceptionCaught , filterClose , filterWrite , init , messageReceived , messageSent , onPostAdd , onPostRemove , onPreAdd , onPreRemove , sessionClosed , sessionCreated , sessionIdle , sessionOpened |
COMPRESSION_DEFAULT
public static final int COMPRESSION_DEFAULT
The default compression level used. Provides the best balance
between speed and compression
COMPRESSION_MAX
public static final int COMPRESSION_MAX
Max compression level. Will give the highest compression ratio, but
will also take more cpu time and is the slowest.
COMPRESSION_MIN
public static final int COMPRESSION_MIN
Provides the best speed at the price of a low compression ratio.
COMPRESSION_NONE
public static final int COMPRESSION_NONE
No compression done on the data.
DISABLE_COMPRESSION_ONCE
public static final String DISABLE_COMPRESSION_ONCE
A flag that allows you to disable compression once.
CompressionFilter
public CompressionFilter()
Creates a new instance which compresses outboud data and decompresses
inbound data with default compression level.
CompressionFilter
public CompressionFilter(boolean compressInbound,
boolean compressOutbound,
int compressionLevel)
Creates a new instance.
CompressionFilter
public CompressionFilter(int compressionLevel)
Creates a new instance which compresses outboud data and decompresses
inbound data with the specified compressionLevel.
isCompressInbound
public boolean isCompressInbound()
Returns true if incoming data is being compressed.
isCompressOutbound
public boolean isCompressOutbound()
Returns true if the filter is compressing data being written.
setCompressInbound
public void setCompressInbound(boolean compressInbound)
Sets if incoming data has to be compressed.
setCompressOutbound
public void setCompressOutbound(boolean compressOutbound)
Set if outgoing data has to be compressed.