X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fibex%2Fjetty%2FJetty.java;h=d84a6fbddb3159e22b792aa5a1645aafe603a8b2;hb=HEAD;hp=b5fa5feee25fa00985806ebc22b44a0d781136c3;hpb=8280c3aadad02de389ff061c3676542128b03e33;p=org.ibex.jetty.git diff --git a/src/org/ibex/jetty/Jetty.java b/src/org/ibex/jetty/Jetty.java index b5fa5fe..d84a6fb 100644 --- a/src/org/ibex/jetty/Jetty.java +++ b/src/org/ibex/jetty/Jetty.java @@ -27,69 +27,71 @@ public class Jetty { hs.addListener(sl); instance = new Jetty(); try { - ClassLoader cc = Thread.currentThread().getContextClassLoader(); - Thread.currentThread().setContextClassLoader(Jetty.class.getClassLoader()); sl.setHttpServer(hs); - addContexts(Root.root + "/host", null); + Host.init(); + Enumeration e = Host.enumerateHosts(); + while(e.hasMoreElements()) { + Host host = (Host)e.nextElement(); + Log.warn("", "scanning host: " + host.hostname + " at " + host.path); + try { + createContext(host, host.path, 0); + } catch (Exception ex) { + Log.warn(Jetty.class, ex); + } + } hs.start(); - Thread.currentThread().setContextClassLoader(cc); } catch (Exception e) { Log.error(Main.class, e); } return instance; } - private static void addContexts(String path, String host) { - try { - File webinf = new File(path + "/WEB-INF"); - if (webinf.exists()) { - String pad = ""; - while(pad.length() + host.length() < 30) pad += " "; - try { - InetAddress.getByName(host); - Log.info(Main.class, pad + host + " => " + path); - WebApplicationContext context = hs.addWebApplication(host, "", path); - context.getServletHandler().getHttpContext().setParentClassLoader(Jetty.class.getClassLoader()); - context.setClassLoaderJava2Compliant(true); - context.setClassLoader(new TreeClassLoader(webinf, Jetty.class.getClassLoader())); - context.setParentClassLoader(Jetty.class.getClassLoader()); - context.setResourceBase(path+"/"); - - ServletHolder sh = context.addServlet("jsp", "*.jsp", "org.apache.jasper.servlet.JspServlet"); - sh.setInitParameter("fork", "false"); - sh.setInitParameter("mappedfile", "true"); - sh.setInitParameter("keepgenerated", "false"); - sh.setInitOrder(0); - - context.setWelcomeFiles(new String[] { "index.jsp", "index.html", "index.xt", "index.txt" }); - ServletHolder def = context.addServlet("default", "/", "org.mortbay.jetty.servlet.Default"); - def.setInitParameter("acceptRanges", "true"); - def.setInitParameter("dirAllowed", "true"); - def.setInitParameter("putAllowed", "false"); - def.setInitParameter("delAllowed", "false"); - def.setInitParameter("redirectWelcome", "false"); - def.setInitParameter("minGzipLength", "8192"); - def.setInitOrder(0); - - context.setDefaultsDescriptor(null); - context.addHandler(new ResourceHandler()); - context.addHandler(new NotFoundHandler()); - context.setWelcomeFiles(new String[] { "index.jsp", "index.html", "index.xt", "index.txt" }); - - } catch (UnknownHostException e) { - Log.warn(Main.class, pad + host + " => " + e.getClass().getName()); + 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; } - File f = new File(path); - if (!f.isDirectory()) return; - String[] list = f.list(); - for(int i=0; i