Merge remote-tracking branch 'origin/jetty-7' into jetty-8
This commit is contained in:
commit
368523de87
|
@ -31,6 +31,9 @@ import java.nio.channels.WritableByteChannel;
|
||||||
|
|
||||||
import org.eclipse.jetty.io.AbstractBuffer;
|
import org.eclipse.jetty.io.AbstractBuffer;
|
||||||
import org.eclipse.jetty.io.Buffer;
|
import org.eclipse.jetty.io.Buffer;
|
||||||
|
import org.eclipse.jetty.util.IO;
|
||||||
|
import org.eclipse.jetty.util.log.Log;
|
||||||
|
import org.eclipse.jetty.util.log.Logger;
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------------- */
|
||||||
/**
|
/**
|
||||||
|
@ -39,6 +42,8 @@ import org.eclipse.jetty.io.Buffer;
|
||||||
*/
|
*/
|
||||||
public class DirectNIOBuffer extends AbstractBuffer implements NIOBuffer
|
public class DirectNIOBuffer extends AbstractBuffer implements NIOBuffer
|
||||||
{
|
{
|
||||||
|
private static final Logger LOG = Log.getLogger(DirectNIOBuffer.class);
|
||||||
|
|
||||||
protected final ByteBuffer _buf;
|
protected final ByteBuffer _buf;
|
||||||
private ReadableByteChannel _in;
|
private ReadableByteChannel _in;
|
||||||
private InputStream _inStream;
|
private InputStream _inStream;
|
||||||
|
@ -69,13 +74,23 @@ public class DirectNIOBuffer extends AbstractBuffer implements NIOBuffer
|
||||||
public DirectNIOBuffer(File file) throws IOException
|
public DirectNIOBuffer(File file) throws IOException
|
||||||
{
|
{
|
||||||
super(READONLY,NON_VOLATILE);
|
super(READONLY,NON_VOLATILE);
|
||||||
FileInputStream fis = new FileInputStream(file);
|
FileInputStream fis = null;
|
||||||
FileChannel fc = fis.getChannel();
|
FileChannel fc = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
fis = new FileInputStream(file);
|
||||||
|
fc = fis.getChannel();
|
||||||
_buf = fc.map(FileChannel.MapMode.READ_ONLY, 0, file.length());
|
_buf = fc.map(FileChannel.MapMode.READ_ONLY, 0, file.length());
|
||||||
setGetIndex(0);
|
setGetIndex(0);
|
||||||
setPutIndex((int)file.length());
|
setPutIndex((int)file.length());
|
||||||
_access=IMMUTABLE;
|
_access=IMMUTABLE;
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (fc != null) try {fc.close();} catch (IOException e){LOG.ignore(e);}
|
||||||
|
IO.close(fis);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
public boolean isDirect()
|
public boolean isDirect()
|
||||||
|
|
Loading…
Reference in New Issue