Package org.apache.mina.filter.stream
Class FileRegionWriteFilter
- java.lang.Object
-
- org.apache.mina.core.filterchain.IoFilterAdapter
-
- org.apache.mina.filter.stream.AbstractStreamWriteFilter<FileRegion>
-
- org.apache.mina.filter.stream.FileRegionWriteFilter
-
- All Implemented Interfaces:
IoFilter
public class FileRegionWriteFilter extends AbstractStreamWriteFilter<FileRegion>
Filter implementation that converts aFileRegion
toIoBuffer
objects and writes those buffers to the next filter. When end of theFileRegion
has been reached this filter will callIoFilter.NextFilter.messageSent(org.apache.mina.core.session.IoSession, org.apache.mina.core.write.WriteRequest)
using the originalFileRegion
written to the session and notifiesWriteFuture
on the originalWriteRequest
.Normall
FileRegion
objects should be handled by theIoProcessor
but this is not always possible if a filter is being used that needs to modify the contents of the file before sending over the network (i.e. theSslFilter
or a data compression filter.)This filter will ignore written messages which aren't
FileRegion
instances. Such messages will be passed to the next filter directly.NOTE: this filter does not close the file channel in
FileRegion.getFileChannel()
after the data from the file has been written. TheFileChannel
should be closed in eitherIoHandler.messageSent(IoSession,Object)
or in anIoFutureListener
associated with theWriteFuture
.- Author:
- Apache MINA Project
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.mina.core.filterchain.IoFilter
IoFilter.NextFilter
-
-
Field Summary
-
Fields inherited from class org.apache.mina.filter.stream.AbstractStreamWriteFilter
CURRENT_STREAM, CURRENT_WRITE_REQUEST, DEFAULT_STREAM_BUFFER_SIZE, WRITE_REQUEST_QUEUE
-
-
Constructor Summary
Constructors Constructor Description FileRegionWriteFilter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Class<FileRegion>
getMessageClass()
protected IoBuffer
getNextBuffer(FileRegion fileRegion)
-
Methods inherited from class org.apache.mina.filter.stream.AbstractStreamWriteFilter
filterWrite, getWriteBufferSize, messageSent, onPreAdd, setWriteBufferSize
-
Methods inherited from class org.apache.mina.core.filterchain.IoFilterAdapter
destroy, exceptionCaught, filterClose, init, inputClosed, messageReceived, onPostAdd, onPostRemove, onPreRemove, sessionClosed, sessionCreated, sessionIdle, sessionOpened, toString
-
-
-
-
Method Detail
-
getMessageClass
protected Class<FileRegion> getMessageClass()
- Specified by:
getMessageClass
in classAbstractStreamWriteFilter<FileRegion>
-
getNextBuffer
protected IoBuffer getNextBuffer(FileRegion fileRegion) throws IOException
- Specified by:
getNextBuffer
in classAbstractStreamWriteFilter<FileRegion>
- Throws:
IOException
-
-