public class FileRegionWriteFilter extends AbstractStreamWriteFilter<FileRegion>
FileRegion
to IoBuffer
objects and writes those buffers to the next filter. When end of the
FileRegion
has been reached this filter will call
IoFilter.NextFilter.messageSent(org.apache.mina.core.session.IoSession, org.apache.mina.core.write.WriteRequest)
using the
original FileRegion
written to the session and notifies
WriteFuture
on the original
WriteRequest
.
Normall FileRegion
objects should be handled by the
IoProcessor
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. the
SslFilter
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. The FileChannel
should be closed in either
IoHandler.messageSent(IoSession,Object)
or in an IoFutureListener
associated with the
WriteFuture
.
IoFilter.NextFilter
CURRENT_STREAM, CURRENT_WRITE_REQUEST, DEFAULT_STREAM_BUFFER_SIZE, WRITE_REQUEST_QUEUE
Constructor and Description |
---|
FileRegionWriteFilter() |
Modifier and Type | Method and Description |
---|---|
protected Class<FileRegion> |
getMessageClass() |
protected IoBuffer |
getNextBuffer(FileRegion fileRegion) |
filterWrite, getWriteBufferSize, messageSent, onPreAdd, setWriteBufferSize
destroy, event, exceptionCaught, filterClose, init, inputClosed, messageReceived, onPostAdd, onPostRemove, onPreRemove, sessionClosed, sessionCreated, sessionIdle, sessionOpened, toString
protected Class<FileRegion> getMessageClass()
getMessageClass
in class AbstractStreamWriteFilter<FileRegion>
protected IoBuffer getNextBuffer(FileRegion fileRegion) throws IOException
getNextBuffer
in class AbstractStreamWriteFilter<FileRegion>
IOException
Copyright © 2004–2021 Apache MINA Project. All rights reserved.