|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.mina.core.filterchain.IoFilterAdapter
org.apache.mina.filter.buffer.BufferedWriteFilter
public final class BufferedWriteFilter
An IoFilter
implementation used to buffer outgoing WriteRequest
almost
like what BufferedOutputStream
does. Using this filter allows to be less dependent
from network latency. It is also useful when a session is generating very small messages
too frequently and consequently generating unnecessary traffic overhead.
Please note that it should always be placed before the ProtocolCodecFilter
as it only handles WriteRequest
's carrying IoBuffer
objects.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.apache.mina.core.filterchain.IoFilter |
---|
IoFilter.NextFilter |
Field Summary | |
---|---|
static int |
DEFAULT_BUFFER_SIZE
Default buffer size value in bytes. |
Constructor Summary | |
---|---|
BufferedWriteFilter()
Default constructor. |
|
BufferedWriteFilter(int bufferSize)
Constructor which sets buffer size to bufferSize .Uses a default
instance of ConcurrentHashMap . |
|
BufferedWriteFilter(int bufferSize,
LazyInitializedCacheMap<IoSession,IoBuffer> buffersMap)
Constructor which sets buffer size to bufferSize . |
Method Summary | |
---|---|
void |
exceptionCaught(IoFilter.NextFilter nextFilter,
IoSession session,
Throwable cause)
Filters IoHandler.exceptionCaught(IoSession,Throwable)
event. |
void |
filterWrite(IoFilter.NextFilter nextFilter,
IoSession session,
WriteRequest writeRequest)
Filters IoSession.write(Object) method invocation. |
void |
flush(IoSession session)
Flushes the buffered data. |
int |
getBufferSize()
Returns buffer size. |
void |
sessionClosed(IoFilter.NextFilter nextFilter,
IoSession session)
Filters IoHandler.sessionClosed(IoSession) event. |
void |
setBufferSize(int bufferSize)
Sets the buffer size but only for the newly created buffers. |
Methods inherited from class org.apache.mina.core.filterchain.IoFilterAdapter |
---|
destroy, filterClose, init, messageReceived, messageSent, onPostAdd, onPostRemove, onPreAdd, onPreRemove, sessionCreated, sessionIdle, sessionOpened, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_BUFFER_SIZE
Constructor Detail |
---|
public BufferedWriteFilter()
DEFAULT_BUFFER_SIZE
bytes. Uses a default instance of ConcurrentHashMap
.
public BufferedWriteFilter(int bufferSize)
bufferSize
.Uses a default
instance of ConcurrentHashMap
.
bufferSize
- the new buffer sizepublic BufferedWriteFilter(int bufferSize, LazyInitializedCacheMap<IoSession,IoBuffer> buffersMap)
bufferSize
. If
buffersMap
is null then a default instance of ConcurrentHashMap
is created else the provided instance is used.
bufferSize
- the new buffer sizebuffersMap
- the map to use for storing each session bufferMethod Detail |
---|
public int getBufferSize()
public void setBufferSize(int bufferSize)
bufferSize
- the new buffer sizepublic void filterWrite(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws Exception
IoSession.write(Object)
method invocation.
filterWrite
in interface IoFilter
filterWrite
in class IoFilterAdapter
Exception
- if writeRequest.message
isn't an
IoBuffer
instance.public void flush(IoSession session)
session
- the session where buffer will be writtenpublic void exceptionCaught(IoFilter.NextFilter nextFilter, IoSession session, Throwable cause) throws Exception
IoHandler.exceptionCaught(IoSession,Throwable)
event.
exceptionCaught
in interface IoFilter
exceptionCaught
in class IoFilterAdapter
Exception
public void sessionClosed(IoFilter.NextFilter nextFilter, IoSession session) throws Exception
IoHandler.sessionClosed(IoSession)
event.
sessionClosed
in interface IoFilter
sessionClosed
in class IoFilterAdapter
Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |