I am building Java web applications, and I hate the traditional \"code-compile-deploy-test\" cycle. I want to type in one tiny change, then see the result INSTANTLY, without
When using embedded Jetty 8.1.10, the 'useFileMappedBuffer=false' setting doesn't work any mode. I read the code for DefaultServlet
, and it reads the property but it's not used for anything.
Instead I looked at where the buffer creation was configured, and found I could subclass SelectChannelConnector
to get the benefits of Continuation, but without locking files on windows. If you simply use org.mortbay.jetty.bio.SocketConnector
, then you will not get continuation support.
Here is my example:
import org.eclipse.jetty.io.Buffers.Type;
import org.eclipse.jetty.server.nio.SelectChannelConnector;
/**
* A Connector that has the advantages NIO, but doesn't lock files in Windows by
* avoiding memory mapped buffers.
*
* It used to be that you could avoid this problem by setting "useFileMappedBuffer" as described in
* http://stackoverflow.com/questions/184312/how-to-make-jetty-dynamically-load-static-pages
* However that approach doesn't seem to work in newer versions of jetty.
*
* @author David Roussel
*
*/
public class SelectChannelConnectorNonLocking extends SelectChannelConnector {
public SelectChannelConnectorNonLocking() {
super();
// Override AbstractNIOConnector and use all indirect buffers
_buffers.setRequestBufferType(Type.INDIRECT);
_buffers.setRequestHeaderType(Type.INDIRECT);
_buffers.setResponseBufferType(Type.INDIRECT);
_buffers.setResponseHeaderType(Type.INDIRECT);
}
}
I've tested this for the locking problem, and it fixes the problem. I've not tested that it works with Continuations yet.