org.apache.mina.filter.stream
Class FileRegionWriteFilter

java.lang.Object
  extended by org.apache.mina.core.filterchain.IoFilterAdapter
      extended by org.apache.mina.filter.stream.AbstractStreamWriteFilter<FileRegion>
          extended by org.apache.mina.filter.stream.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(IoSession,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.

Version:
$Rev$, $Date$
Author:
The Apache MINA Project (dev@mina.apache.org)

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
FileRegionWriteFilter()
           
 
Method Summary
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, messageReceived, onPostAdd, onPostRemove, onPreRemove, sessionClosed, sessionCreated, sessionIdle, sessionOpened, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileRegionWriteFilter

public FileRegionWriteFilter()
Method Detail

getMessageClass

protected Class<FileRegion> getMessageClass()
Specified by:
getMessageClass in class AbstractStreamWriteFilter<FileRegion>

getNextBuffer

protected IoBuffer getNextBuffer(FileRegion fileRegion)
                          throws IOException
Specified by:
getNextBuffer in class AbstractStreamWriteFilter<FileRegion>
Throws:
IOException


Copyright © 2004-2010 Apache MINA Project. All Rights Reserved.