Make sure Jetty contexts are properly mapped each time an application is bound or unbound. Remove code for dead responseEncoding property.

This commit is contained in:
hns 2009-09-20 19:43:05 +00:00
parent b65a8d5c6d
commit fc689d9a12

View file

@ -323,7 +323,6 @@ public class ApplicationManager implements XmlRpcHandler {
String uploadLimit; String uploadLimit;
String uploadSoftfail; String uploadSoftfail;
String debug; String debug;
boolean encode;
Repository[] repositories; Repository[] repositories;
String servletClassName; String servletClassName;
@ -359,7 +358,6 @@ public class ApplicationManager implements XmlRpcHandler {
uploadLimit = conf.getProperty("uploadLimit"); uploadLimit = conf.getProperty("uploadLimit");
uploadSoftfail = conf.getProperty("uploadSoftfail"); uploadSoftfail = conf.getProperty("uploadSoftfail");
debug = conf.getProperty("debug"); debug = conf.getProperty("debug");
encode = "true".equalsIgnoreCase(conf.getProperty("responseEncoding"));
String appDirName = conf.getProperty("appdir"); String appDirName = conf.getProperty("appdir");
appDir = (appDirName == null) ? null : getAbsoluteFile(appDirName); appDir = (appDirName == null) ? null : getAbsoluteFile(appDirName);
String dbDirName = conf.getProperty("dbdir"); String dbDirName = conf.getProperty("dbdir");
@ -481,7 +479,6 @@ public class ApplicationManager implements XmlRpcHandler {
if (jetty != null) { if (jetty != null) {
if(context == null) { if(context == null) {
context = new ContextHandlerCollection(); context = new ContextHandlerCollection();
context.mapContexts();
jetty.getHttpServer().setHandler(context); jetty.getHttpServer().setHandler(context);
} }
@ -490,10 +487,8 @@ public class ApplicationManager implements XmlRpcHandler {
File staticContent = getAbsoluteFile(staticDir); File staticContent = getAbsoluteFile(staticDir);
getLogger().info("Serving static from " + getLogger().info("Serving static from " + staticContent.getPath());
staticContent.getPath()); getLogger().info("Mounting static at " + staticMountpoint);
getLogger().info("Mounting static at " +
staticMountpoint);
ResourceHandler rhandler = new ResourceHandler(); ResourceHandler rhandler = new ResourceHandler();
rhandler.setResourceBase(staticContent.getPath()); rhandler.setResourceBase(staticContent.getPath());
@ -507,12 +502,6 @@ public class ApplicationManager implements XmlRpcHandler {
appContext = context.addContext(pathPattern, ""); appContext = context.addContext(pathPattern, "");
if (encode) {
// FIXME: ContentEncodingHandler is broken/removed in Jetty 4.2
// context.addHandler(new ContentEncodingHandler());
getLogger().warn("Warning: disabling response encoding for Jetty 4.2 compatibility");
}
ServletHandler handler = new ServletHandler(); ServletHandler handler = new ServletHandler();
Class servletClass = servletClassName == null ? Class servletClass = servletClassName == null ?
EmbeddedServletClient.class : Class.forName(servletClassName); EmbeddedServletClient.class : Class.forName(servletClassName);
@ -556,13 +545,14 @@ public class ApplicationManager implements XmlRpcHandler {
protectedContent.getPath()); protectedContent.getPath());
} }
// Remap the context paths and start
context.mapContexts();
appContext.start(); appContext.start();
} }
// register as XML-RPC handler // register as XML-RPC handler
xmlrpcHandlerName = app.getXmlRpcHandlerName(); xmlrpcHandlerName = app.getXmlRpcHandlerName();
xmlrpcHandlers.put(xmlrpcHandlerName, app); xmlrpcHandlers.put(xmlrpcHandlerName, app);
// app.start();
} catch (Exception x) { } catch (Exception x) {
getLogger().error("Couldn't bind app", x); getLogger().error("Couldn't bind app", x);
x.printStackTrace(); x.printStackTrace();
@ -576,16 +566,19 @@ public class ApplicationManager implements XmlRpcHandler {
// unbind from Jetty HTTP server // unbind from Jetty HTTP server
if (jetty != null) { if (jetty != null) {
if (appContext != null) { if (appContext != null) {
context.removeHandler(appContext);
appContext.stop(); appContext.stop();
appContext.destroy(); appContext.destroy();
appContext = null; appContext = null;
} }
if (staticContext != null) { if (staticContext != null) {
context.removeHandler(staticContext);
staticContext.stop(); staticContext.stop();
staticContext.destroy(); staticContext.destroy();
staticContext = null; staticContext = null;
} }
context.mapContexts();
} }
// unregister as XML-RPC handler // unregister as XML-RPC handler