Enumeration e = Host.enumerateHosts();
while(e.hasMoreElements()) {
Host host = (Host)e.nextElement();
+ Log.warn("", "scanning host: " + host.hostname + " at " + host.path);
try {
- createContext(host);
+ createContext(host, host.path, 0);
} catch (Exception ex) {
Log.warn(Jetty.class, ex);
}
return instance;
}
- private static void createContext(Host host) throws Exception {
- WebApplicationContext context = new WebApplicationContext(host.path);
- context.setContextPath("");
+ private static void createContext(Host host, String path, int depth) throws Exception {
+ Log.warn(host, "scanning " + path);
+ if (!new File(path+"/WEB-INF/web.xml").exists()) {
+ if (depth >= 4) return;
+ for(String s : new File(path).list()) {
+ if (new File(path+"/"+s).isDirectory()) {
+ try {
+ createContext(host, path+"/"+s, depth+1);
+ } catch (Exception ex) {
+ Log.warn(Jetty.class, ex);
+ }
+ }
+ }
+ return;
+ }
+ WebApplicationContext context = new WebApplicationContext(path);
+ String webPath = path.substring(host.path.length());
+ if (webPath.endsWith("/_")) webPath = webPath.substring(0, webPath.length()-1);
+ if (webPath.endsWith("/_/")) webPath = webPath.substring(0, webPath.length()-2);
+ System.out.println("mapping " + webPath + " as " + path);
+ context.setContextPath(webPath);
hs.addContext(host.hostname, context);
//context.getServletHandler().getHttpContext().setParentClassLoader(Jetty.class.getClassLoader()); // ???
context.setClassLoaderJava2Compliant(true);
- context.setClassLoader(host);
+ context.setClassLoader(new TreeClassLoader(new File(path+"/WEB-INF"), host));
//context.setParentClassLoader(Jetty.class.getClassLoader());
- context.setResourceBase(host.path+"/");
+ context.setResourceBase(path+"/");
ServletHolder sh = context.addServlet("jsp", "*.jsp", "org.apache.jasper.servlet.JspServlet");
sh.setInitParameter("fork", "false");