From 9085d1d0a5f40d4bdc14e3cd83847b75b90d8bdc Mon Sep 17 00:00:00 2001 From: adam Date: Sun, 9 Jul 2006 06:45:27 +0000 Subject: [PATCH] hackage darcs-hash:20060709064527-5007d-78873af34d5308f5ad4a5883e11c9cea3569b232.gz --- src/org/ibex/jetty/Jetty.java | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/src/org/ibex/jetty/Jetty.java b/src/org/ibex/jetty/Jetty.java index cba21a9..d84a6fb 100644 --- a/src/org/ibex/jetty/Jetty.java +++ b/src/org/ibex/jetty/Jetty.java @@ -32,8 +32,9 @@ public class Jetty { 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); } @@ -43,15 +44,33 @@ public class Jetty { 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"); -- 1.7.10.4