org.apache.mina.filter
Class StreamWriteFilter
- IoFilter
public class StreamWriteFilter
Filter implementation which makes it possible to write
InputStream
objects directly using
IoSession.write(Object)
. When an
InputStream
is written to a session this filter will read the bytes
from the stream into
ByteBuffer
objects and write those buffers
to the next filter. When end of stream has been reached this filter will
call
NextFilter.messageSent(IoSession, Object)
using the original
InputStream
written to the session and notifies
WriteFuture
on the
original
IoFilter.WriteRequest
.
This filter will ignore written messages which aren't
InputStream
instances. Such messages will be passed to the next filter directly.
NOTE: this filter does not close the stream after all data from stream
has been written. The
IoHandler
should take
care of that in its
IoHandler.messageSent(IoSession,Object)
callback.
destroy , exceptionCaught , filterClose , filterWrite , init , messageReceived , messageSent , onPostAdd , onPostRemove , onPreAdd , onPreRemove , sessionClosed , sessionCreated , sessionIdle , sessionOpened |
CURRENT_STREAM
public static final String CURRENT_STREAM
The attribute name used when binding the InputStream
to the session.
DEFAULT_STREAM_BUFFER_SIZE
public static final int DEFAULT_STREAM_BUFFER_SIZE
The default buffer size this filter uses for writing.
INITIAL_WRITE_FUTURE
protected static final String INITIAL_WRITE_FUTURE
WRITE_REQUEST_QUEUE
protected static final String WRITE_REQUEST_QUEUE
getWriteBufferSize
public int getWriteBufferSize()
Returns the size of the write buffer in bytes. Data will be read from the
stream in chunks of this size and then written to the next filter.
setWriteBufferSize
public void setWriteBufferSize(int writeBufferSize)
Sets the size of the write buffer in bytes. Data will be read from the
stream in chunks of this size and then written to the next filter.
void filterWrite
public @Override void filterWrite(NextFilter nextFilter,
IoSession session,
WriteRequest writeRequest)
throws Exception
void messageSent
public @Override void messageSent(NextFilter nextFilter,
IoSession session,
Object message)
throws Exception