Class FileRegionWriteFilter

All Implemented Interfaces:
IoFilter

public class FileRegionWriteFilter extends AbstractStreamWriteFilter<FileRegion>
Filter implementation that converts a 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.