Update of /cvsroot/jicarilla/jicarilla-sandbox/platform/components/http/impl/src/java/org/jicarilla/http/plumbing
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23278/platform/components/http/impl/src/java/org/jicarilla/http/plumbing
Modified Files:
FilesystemStage.java
Log Message:
split out the response population logic from the filesystem stage
Index: FilesystemStage.java
===================================================================
RCS file: /cvsroot/jicarilla/jicarilla-sandbox/platform/components/http/impl/src/java/org/jicarilla/http/plumbing/FilesystemStage.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- FilesystemStage.java 11 Jan 2004 12:28:11 -0000 1.3
+++ FilesystemStage.java 20 Feb 2004 14:18:49 -0000 1.4
@@ -30,6 +30,7 @@
import org.jicarilla.http.HTTPEncoding;
import org.jicarilla.http.HTTPException;
import org.jicarilla.http.HTTPMessage;
+import org.jicarilla.http.HTTPFileReader;
import org.jicarilla.io.Filesystem;
import java.io.IOException;
@@ -44,27 +45,28 @@
*/
public class FilesystemStage extends AbstractStage
{
- public final static int BUFFER_SIZE = 8096;
-
- private Filesystem m_filesystem;
+ protected HTTPFileReader m_fileReader;
- public FilesystemStage( Channel queue, Sink errorHandler, Filesystem fs )
+ public FilesystemStage( Channel queue, Sink errorHandler, HTTPFileReader fr )
{
super( queue, errorHandler );
- setFilesystem( fs );
+ setFileReader( fr);
}
- public Filesystem getFilesystem()
+ public HTTPFileReader getFileReader()
{
- return m_filesystem;
+ return m_fileReader;
}
- public void setFilesystem( Filesystem filesystem )
+ public void setFileReader( HTTPFileReader fileReader )
{
- m_filesystem = filesystem;
+ m_fileReader = fileReader;
}
+ /**
+ * @todo: processing of the URL to extract the filename
+ */
protected void process( HTTPEvent e )
throws HTTPException, IOException
{
@@ -73,23 +75,7 @@
String file = req.getField2String();
- ReadableByteChannel rbc = getFilesystem().getFile( file );
- int size = 0;
- while(true)
- {
- ByteBuffer buf = ByteBuffer.allocate( BUFFER_SIZE );
- int read = rbc.read( buf );
- if(read < 0)
- break;
- if(read == 0)
- continue;
-
- size += read;
- buf.rewind();
- buf.limit(read);
- res.addBodyPart(buf);
- }
- getFilesystem().returnFile( rbc );
+ int size = m_fileReader.readFile( file, res );
res.addHeader( HTTPEncoding.HEADER_CONTENT_LENGTH,
""+size );
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.