- 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 = new WebApplicationContext(path);
- context.setContextPath("");
- hs.addContext(host, context);
- 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);
+ }