X-Git-Url: http://git.megacz.com/?p=org.ibex.jinetd.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fjinetd%2FRoot.java;h=5dd716836de9634e20e453b5023c78318a7cde98;hp=49bcf39624f5abb901015ca4747971a0f921a66f;hb=501b9089d3cf777fc417d9bcddba9bc542a086f9;hpb=583587a3f34a3d2939bcc2b7bcab51b871f2b0c7 diff --git a/src/org/ibex/jinetd/Root.java b/src/org/ibex/jinetd/Root.java index 49bcf39..5dd7168 100644 --- a/src/org/ibex/jinetd/Root.java +++ b/src/org/ibex/jinetd/Root.java @@ -8,64 +8,59 @@ import java.io.*; import java.util.*; import java.net.*; -public class Root extends Loader { +public class Root extends Watcher { - public static String root = System.getProperty("jinetd.root", null); - - private final Host host; - private final Watched port; + private final PortDir port; private static final ThreadPool tp = new ThreadPool(10, 100); - public Root(String path) { + public Root(String path) throws IOException { super(path); - host = new Host(path + File.separatorChar + "host", null); + if (!new File(path + File.separatorChar + "host").exists()) new File(path + File.separatorChar + "host").mkdirs(); + if (!new File(path + File.separatorChar + "port").exists()) new File(path + File.separatorChar + "port").mkdirs(); port = new PortDir(path + File.separatorChar + "port"); + watch(path + File.separatorChar + "host"); + watch(path + File.separatorChar + "port"); + scan(); } - public Watched slash(String part) { - if (part.equals("host")) return host; - if (part.equals("port")) return port; - if (part.equals("LIB")) return super.slash(part); - if (part.endsWith(".jar")) return super.slash(part); - return null; - } - - public static void reboot() { - Log.flush(); - System.exit(0); - } - - public void changed(Watched w) { - if (w.part.equals("host")) { - Log.debug(this, "/host changed"); - } else if (w.part.equals("port")) { - Log.debug(this, "/port changed"); - } else if (w.getAbsolutePath().endsWith(".jar")) { + public void changed(File w) throws IOException { + if (w.getName().equals("host")) Log.debug(this, "/host changed"); + else if (w.getName().equals("port")) Log.debug(this, "/port changed"); + /* + else if (w.getAbsolutePath().endsWith(".jar")) { if (w.lastModifiedAtLastScan != -1) { Log.error(this, "jinetd upgraded; bouncing the JVM...."); - reboot(); - } - } else { - Log.debug(this, "unknown directory " + w.part + " changed"); - } + Main.reboot(); + } } + */ + else Log.debug(this, "unknown directory " + w.getAbsolutePath() + " changed"); } - private static class PortDir extends Watched { - public PortDir(String path) { super(path); } - public Watched slash(String part) { + private static class PortDir extends Watcher { + public PortDir(String path) throws IOException { + super(path); + String[] ports = new File(path).list(); + for(int i=0; i