|
||||||||||
| 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.stream.StreamWriteFilter
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 IoBuffer objects and write those buffers
to the next filter. When end of stream has been reached this filter will
call IoFilter.NextFilter#messageSent(IoSession,WriteRequest) using the original
InputStream written to the session and notifies
WriteFuture on the
original WriteRequest.
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.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface org.apache.mina.common.IoFilter |
|---|
IoFilter.NextFilter |
| Field Summary | |
|---|---|
static AttributeKey |
CURRENT_STREAM
The attribute name used when binding the InputStream to the session. |
static int |
DEFAULT_STREAM_BUFFER_SIZE
The default buffer size this filter uses for writing. |
| Constructor Summary | |
|---|---|
StreamWriteFilter()
|
|
| Method Summary | |
|---|---|
void |
filterWrite(IoFilter.NextFilter nextFilter,
IoSession session,
WriteRequest writeRequest)
Filters IoSession.write(Object) method invocation. |
int |
getWriteBufferSize()
Returns the size of the write buffer in bytes. |
void |
messageSent(IoFilter.NextFilter nextFilter,
IoSession session,
WriteRequest writeRequest)
Filters IoHandler.messageSent(IoSession,Object)
event. |
void |
onPreAdd(IoFilterChain parent,
String name,
IoFilter.NextFilter nextFilter)
Invoked before this filter is added to the specified parent. |
void |
setWriteBufferSize(int writeBufferSize)
Sets the size of the write buffer in bytes. |
| Methods inherited from class org.apache.mina.common.IoFilterAdapter |
|---|
destroy, exceptionCaught, filterClose, filterSetTrafficMask, init, messageReceived, onPostAdd, onPostRemove, 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 DEFAULT_STREAM_BUFFER_SIZE
public static final AttributeKey CURRENT_STREAM
InputStream to the session.
| Constructor Detail |
|---|
public StreamWriteFilter()
| Method Detail |
|---|
public void onPreAdd(IoFilterChain parent,
String name,
IoFilter.NextFilter nextFilter)
throws Exception
IoFilterIoFilter.init() is invoked.
onPreAdd in interface IoFilteronPreAdd in class IoFilterAdapterparent - the parent who called this methodname - the name assigned to this filternextFilter - the IoFilter.NextFilter for this filter. You can reuse
this object until this filter is removed from the chain.
Exception
public void filterWrite(IoFilter.NextFilter nextFilter,
IoSession session,
WriteRequest writeRequest)
throws Exception
IoFilterIoSession.write(Object) method invocation.
filterWrite in interface IoFilterfilterWrite in class IoFilterAdapterException
public void messageSent(IoFilter.NextFilter nextFilter,
IoSession session,
WriteRequest writeRequest)
throws Exception
IoFilterIoHandler.messageSent(IoSession,Object)
event.
messageSent in interface IoFiltermessageSent in class IoFilterAdapterExceptionpublic int getWriteBufferSize()
public void setWriteBufferSize(int writeBufferSize)
IllegalArgumentException - if the specified size is < 1.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||