Log.setLog(new JettyTreeLogger(branch));
// Turn off XML validation.
System.setProperty("org.mortbay.xml.XmlParser.Validating", "false");
AbstractConnector connector = getConnector();
connector.setPort(port);
// Don't share ports with an existing process.
connector.setReuseAddress(false);
// Linux keeps the port blocked after shutdown if we don't disable this.
connector.setSoLingerTime(0);
Server server = new Server();
server.addConnector(connector);
// Create a new web app in the war directory.
WebAppContext wac = new WebAppContextWithReload(logger,
appRootDir.getAbsolutePath(), "/");
RequestLogHandler logHandler = new RequestLogHandler();
logHandler.setRequestLog(new JettyRequestLogger(logger));
logHandler.setHandler(wac);
server.setHandler(logHandler);
server.start();
server.setStopAtShutdown(true);
// Now that we're started, log to the top level logger.
Log.setLog(new JettyTreeLogger(logger));
return new JettyServletContainer(logger, server, wac,
connector.getLocalPort(), appRootDir);
}