|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.mina.common.IoFilterAdapter
org.apache.mina.filter.CompressionFilter
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.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.apache.mina.common.IoFilter |
---|
org.apache.mina.common.IoFilter.NextFilter, org.apache.mina.common.IoFilter.WriteRequest |
Field Summary | |
---|---|
static int |
COMPRESSION_DEFAULT
The default compression level used. |
static int |
COMPRESSION_MAX
Max compression level. |
static int |
COMPRESSION_MIN
Provides the best speed at the price of a low compression ratio. |
static int |
COMPRESSION_NONE
No compression done on the data. |
static java.lang.String |
DISABLE_COMPRESSION_ONCE
A flag that allows you to disable compression once. |
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
void |
filterWrite(org.apache.mina.common.IoFilter.NextFilter nextFilter,
org.apache.mina.common.IoSession session,
org.apache.mina.common.IoFilter.WriteRequest writeRequest)
|
boolean |
isCompressInbound()
Returns true if incoming data is being compressed. |
boolean |
isCompressOutbound()
Returns true if the filter is compressing data being written. |
void |
messageReceived(org.apache.mina.common.IoFilter.NextFilter nextFilter,
org.apache.mina.common.IoSession session,
java.lang.Object message)
|
void |
onPostRemove(org.apache.mina.common.IoFilterChain parent,
java.lang.String name,
org.apache.mina.common.IoFilter.NextFilter nextFilter)
|
void |
onPreAdd(org.apache.mina.common.IoFilterChain parent,
java.lang.String name,
org.apache.mina.common.IoFilter.NextFilter nextFilter)
|
void |
setCompressInbound(boolean compressInbound)
Sets if incoming data has to be compressed. |
void |
setCompressOutbound(boolean compressOutbound)
Set if outgoing data has to be compressed. |
Methods inherited from class org.apache.mina.common.IoFilterAdapter |
---|
destroy, exceptionCaught, filterClose, init, messageSent, onPostAdd, onPreRemove, sessionClosed, sessionCreated, sessionIdle, sessionOpened |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int COMPRESSION_MAX
public static final int COMPRESSION_MIN
public static final int COMPRESSION_NONE
public static final int COMPRESSION_DEFAULT
public static final java.lang.String DISABLE_COMPRESSION_ONCE
Constructor Detail |
---|
public CompressionFilter()
public CompressionFilter(int compressionLevel)
compressionLevel
- the level of compression to be used. Must
be one of COMPRESSION_DEFAULT
,
COMPRESSION_MAX
,
COMPRESSION_MIN
, and
COMPRESSION_NONE
.public CompressionFilter(boolean compressInbound, boolean compressOutbound, int compressionLevel)
compressInbound
- true if data read is to be decompressedcompressOutbound
- true if data written is to be compressedcompressionLevel
- the level of compression to be used. Must
be one of COMPRESSION_DEFAULT
,
COMPRESSION_MAX
,
COMPRESSION_MIN
, and
COMPRESSION_NONE
.Method Detail |
---|
public void messageReceived(org.apache.mina.common.IoFilter.NextFilter nextFilter, org.apache.mina.common.IoSession session, java.lang.Object message) throws java.lang.Exception
messageReceived
in interface org.apache.mina.common.IoFilter
messageReceived
in class org.apache.mina.common.IoFilterAdapter
java.lang.Exception
public void filterWrite(org.apache.mina.common.IoFilter.NextFilter nextFilter, org.apache.mina.common.IoSession session, org.apache.mina.common.IoFilter.WriteRequest writeRequest) throws java.io.IOException
filterWrite
in interface org.apache.mina.common.IoFilter
filterWrite
in class org.apache.mina.common.IoFilterAdapter
java.io.IOException
public void onPreAdd(org.apache.mina.common.IoFilterChain parent, java.lang.String name, org.apache.mina.common.IoFilter.NextFilter nextFilter) throws java.lang.Exception
onPreAdd
in interface org.apache.mina.common.IoFilter
onPreAdd
in class org.apache.mina.common.IoFilterAdapter
java.lang.Exception
public boolean isCompressInbound()
public void setCompressInbound(boolean compressInbound)
public boolean isCompressOutbound()
public void setCompressOutbound(boolean compressOutbound)
public void onPostRemove(org.apache.mina.common.IoFilterChain parent, java.lang.String name, org.apache.mina.common.IoFilter.NextFilter nextFilter) throws java.lang.Exception
onPostRemove
in interface org.apache.mina.common.IoFilter
onPostRemove
in class org.apache.mina.common.IoFilterAdapter
java.lang.Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |