server = createServer();
// SunJsseListener listener = new SunJsseListener();
String keystorePassword = contextConfiguration
.retrieveProperty(new ContextKey("webServer.keystore.sslCertificate.password"));
if (keystorePassword.equals("")) {
throw new Exception(
"Private key / certificate password has not been set. Please run the Installation Wizard.");
}
actualPort = defaultPort == -1 ? contextConfiguration.retrievePropertyInt(new ContextKey("webServer.port")) : defaultPort;
String bind = contextConfiguration.retrieveProperty(new ContextKey("webServer.bindAddress"));
listeners = new ArrayList<SocketListener>();
PropertyList l = new PropertyList(bind.equals("") ? "0.0.0.0" : bind);
for (Iterator<String> i = l.iterator(); i.hasNext();) {
String address = i.next();
if (log.isInfoEnabled())
log.info("Adding listener on " + address + ":" + actualPort);
if (!serverLock.isStarted()) {
serverLock.start(actualPort);
}
SocketListener listener = null;
if (contextConfiguration.retrieveProperty(new ContextKey("webServer.protocol")).equals("http")) {
listener = new SocketListener();
log.warn("The server is configured to listen for plain HTTP connections.");
} else {
listener = new CustomJsseListener(keystorePassword);
MsieSslHandler sslHandler = new MsieSslHandler();
sslHandler.setUserAgentSubString("MSIE 5");
listener.setHttpHandler(sslHandler);
}
listener.setPort(actualPort);
listener.setMinThreads(contextConfiguration.retrievePropertyInt(new ContextKey("webServer.minThreads")));
listener.setMaxThreads(contextConfiguration.retrievePropertyInt(new ContextKey("webServer.maxThreads")));
listener.setMaxIdleTimeMs(contextConfiguration.retrievePropertyInt(new ContextKey("webServer.maxIdleTimeMs")));
listener.setHost(address);
listener.setBufferSize(contextConfiguration.retrievePropertyInt(new ContextKey("webServer.bufferSize")));
listener.setBufferReserve(contextConfiguration.retrievePropertyInt(new ContextKey("webServer.bufferReserve")));
listener.setTcpNoDelay(contextConfiguration.retrievePropertyBoolean(new ContextKey("webServer.tcpNoDelay")));
listener.setThreadsPriority(contextConfiguration.retrievePropertyInt(new ContextKey("webServer.threadPriority")));
listeners.add(listener);
listener.setLowResourcePersistTimeMs(contextConfiguration.retrievePropertyInt(new ContextKey(
"webServer.lowResourcePersistTimeMs")));
listener.setPoolName("main");
server.addListener(listener);
}
// Add the context
getBootProgressMonitor().updateMessage("Creating web application");
getBootProgressMonitor().updateProgress(9);
httpContext = new CustomHttpContext(server, "/", useDevConfig, bootLoader);
httpContext.setRedirectNullPath(false);
server.addContext(httpContext);
// Dunny servlet handler for faking HttpServletRequest,
// HttpServletResponse
servletHandler = new ServletHandler();
servletHandler.initialize(httpContext);
servletHandler.start();
// Add the webapp
webappContext = new CustomWebApplicationContext(useDevConfig, bootLoader);
addLifecycleListener(webappContext);
server.addContext(webappContext);
webappContext.setRedirectNullPath(false);
// Configure the server
server.setRequestsPerGC(contextConfiguration.retrievePropertyInt(new ContextKey("webServer.requestsPerGC")));
server.setTrace(false);
// Set the request log
if (contextConfiguration.retrievePropertyBoolean(new ContextKey("webServer.requestLog"))) {
NCSARequestLog requestLog = new NCSARequestLog(jettyLog);
requestLog.setRetainDays(90);
requestLog.setAppend(true);
requestLog.setExtended(false);
requestLog.setBuffered(false);