Package org.apache.mina.filter.stream
Class AbstractStreamWriteFilter<T>
- java.lang.Object
-
- org.apache.mina.core.filterchain.IoFilterAdapter
-
- org.apache.mina.filter.stream.AbstractStreamWriteFilter<T>
-
- Type Parameters:
T
- The type of Stream
- All Implemented Interfaces:
IoFilter
- Direct Known Subclasses:
FileRegionWriteFilter
,StreamWriteFilter
public abstract class AbstractStreamWriteFilter<T> extends IoFilterAdapter
Filter implementation which makes it possible to write Stream objects directly usingIoSession.write(Object)
.- Author:
- Apache MINA Project
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.mina.core.filterchain.IoFilter
IoFilter.NextFilter
-
-
Field Summary
Fields Modifier and Type Field Description protected static AttributeKey
CURRENT_STREAM
The attribute name used when binding the streaming object to the session.protected static AttributeKey
CURRENT_WRITE_REQUEST
static int
DEFAULT_STREAM_BUFFER_SIZE
The default buffer size this filter uses for writing.protected static AttributeKey
WRITE_REQUEST_QUEUE
-
Constructor Summary
Constructors Constructor Description AbstractStreamWriteFilter()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
filterWrite(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest)
FiltersIoSession.write(Object)
method invocation.protected abstract Class<T>
getMessageClass()
protected abstract IoBuffer
getNextBuffer(T message)
int
getWriteBufferSize()
void
messageSent(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest)
FiltersIoHandler.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.core.filterchain.IoFilterAdapter
destroy, exceptionCaught, filterClose, init, inputClosed, messageReceived, onPostAdd, onPostRemove, onPreRemove, sessionClosed, sessionCreated, sessionIdle, sessionOpened, toString
-
-
-
-
Field Detail
-
DEFAULT_STREAM_BUFFER_SIZE
public static final int DEFAULT_STREAM_BUFFER_SIZE
The default buffer size this filter uses for writing.- See Also:
- Constant Field Values
-
CURRENT_STREAM
protected static final AttributeKey CURRENT_STREAM
The attribute name used when binding the streaming object to the session.
-
WRITE_REQUEST_QUEUE
protected static final AttributeKey WRITE_REQUEST_QUEUE
-
CURRENT_WRITE_REQUEST
protected static final AttributeKey CURRENT_WRITE_REQUEST
-
-
Method Detail
-
onPreAdd
public void onPreAdd(IoFilterChain parent, String name, IoFilter.NextFilter nextFilter) throws Exception
Invoked before this filter is added to the specified parent. Please note that this method can be invoked more than once if this filter is added to more than one parents. This method is not invoked beforeIoFilter.init()
is invoked.- Specified by:
onPreAdd
in interfaceIoFilter
- Overrides:
onPreAdd
in classIoFilterAdapter
- Parameters:
parent
- the parent who called this methodname
- the name assigned to this filternextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.- Throws:
Exception
- If an error occurred while processing the event
-
filterWrite
public void filterWrite(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws Exception
FiltersIoSession.write(Object)
method invocation.- Specified by:
filterWrite
in interfaceIoFilter
- Overrides:
filterWrite
in classIoFilterAdapter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which has to process this invocationwriteRequest
- TheWriteRequest
to process- Throws:
Exception
- If an error occurred while processing the event
-
messageSent
public void messageSent(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws Exception
FiltersIoHandler.messageSent(IoSession,Object)
event.- Specified by:
messageSent
in interfaceIoFilter
- Overrides:
messageSent
in classIoFilterAdapter
- Parameters:
nextFilter
- theIoFilter.NextFilter
for this filter. You can reuse this object until this filter is removed from the chain.session
- TheIoSession
which has received this eventwriteRequest
- TheWriteRequest
that contains the sent message- Throws:
Exception
- If an error occurred while processing the event
-
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.- Parameters:
writeBufferSize
- The size of the write buffer- Throws:
IllegalArgumentException
- if the specified size is < 1.
-
getNextBuffer
protected abstract IoBuffer getNextBuffer(T message) throws IOException
- Throws:
IOException
-
-