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
Filter implementation which makes it possible to write Stream
objects directly using
IoSession.write(Object).-
Nested Class Summary
Nested classes/interfaces inherited from interface IoFilter
IoFilter.NextFilter -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final AttributeKeyThe attribute name used when binding the streaming object to the session.protected static final AttributeKeystatic final intThe default buffer size this filter uses for writing.protected static final AttributeKeyprivate int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidfilterWrite(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest) FiltersIoSession.write(Object)method invocation.protected abstract IoBuffergetNextBuffer(T message) intprivate Queue<WriteRequest> getWriteRequestQueue(IoSession session) voidmessageSent(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest) FiltersIoHandler.messageSent(IoSession,Object)event.voidonPreAdd(IoFilterChain parent, String name, IoFilter.NextFilter nextFilter) Invoked before this filter is added to the specifiedparent.private Queue<WriteRequest> removeWriteRequestQueue(IoSession session) voidsetWriteBufferSize(int writeBufferSize) Sets the size of the write buffer in bytes.Methods inherited from class IoFilterAdapter
destroy, event, exceptionCaught, filterClose, init, inputClosed, messageReceived, onPostAdd, onPostRemove, onPreRemove, sessionClosed, sessionCreated, sessionIdle, sessionOpened, toString
-
Field Details
-
DEFAULT_STREAM_BUFFER_SIZE
public static final int DEFAULT_STREAM_BUFFER_SIZEThe default buffer size this filter uses for writing.- See Also:
-
CURRENT_STREAM
The attribute name used when binding the streaming object to the session. -
WRITE_REQUEST_QUEUE
-
CURRENT_WRITE_REQUEST
-
writeBufferSize
private int writeBufferSize
-
-
Constructor Details
-
AbstractStreamWriteFilter
public AbstractStreamWriteFilter()
-
-
Method Details
-
onPreAdd
public void onPreAdd(IoFilterChain parent, String name, IoFilter.NextFilter nextFilter) throws Exception Invoked before this filter is added to the specifiedparent. 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:
onPreAddin interfaceIoFilter- Overrides:
onPreAddin classIoFilterAdapter- Parameters:
parent- the parent who called this methodname- the name assigned to this filternextFilter- theIoFilter.NextFilterfor 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:
filterWritein interfaceIoFilter- Overrides:
filterWritein classIoFilterAdapter- Parameters:
nextFilter- theIoFilter.NextFilterfor this filter. You can reuse this object until this filter is removed from the chain.session- TheIoSessionwhich has to process this invocationwriteRequest- TheWriteRequestto process- Throws:
Exception- If an error occurred while processing the event
-
getMessageClass
-
getWriteRequestQueue
-
removeWriteRequestQueue
-
messageSent
public void messageSent(IoFilter.NextFilter nextFilter, IoSession session, WriteRequest writeRequest) throws Exception FiltersIoHandler.messageSent(IoSession,Object)event.- Specified by:
messageSentin interfaceIoFilter- Overrides:
messageSentin classIoFilterAdapter- Parameters:
nextFilter- theIoFilter.NextFilterfor this filter. You can reuse this object until this filter is removed from the chain.session- TheIoSessionwhich has received this eventwriteRequest- TheWriteRequestthat 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
- Throws:
IOException
-