licensing update to APSL 2.0
[org.ibex.jinetd.git] / src / org / ibex / jinetd / Root.java
index 6b5467d..d89b04c 100644 (file)
@@ -1,3 +1,7 @@
+// Copyright 2000-2005 the Contributors, as shown in the revision logs.
+// Licensed under the Apache Public Source License 2.0 ("the License").
+// You may not use this file except in compliance with the License.
+
 package org.ibex.jinetd;
 import org.ibex.util.*;
 import java.io.*;
@@ -6,7 +10,7 @@ import java.net.*;
 
 public class Root extends Loader {
 
-    public static String root = System.getProperty("jinetd.root", "/jinetd");
+    public static String root = System.getProperty("jinetd.root", null);
     private final Host host;
     private final Watched port;
 
@@ -20,6 +24,7 @@ public class Root extends Loader {
         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;
     }
 
@@ -30,28 +35,28 @@ public class Root extends Loader {
 
     public void changed(Watched w) {
         if (w.part.equals("host")) {
-            Log.warn(this, "/host changed");
+            Log.debug(this, "/host changed");
         } else if (w.part.equals("port")) {
-            Log.warn(this, "/port changed");
-        } else if (w.getAbsolutePath().startsWith(Root.root + "/LIB/")) {
+            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.info(this, "unknown directory " + w.part + " changed");
+            Log.debug(this, "unknown directory " + w.part + " changed");
         }
     }
 
     private static class PortDir extends Watched {
         public PortDir(String path) { super(path); }
         public Watched slash(String part) {
-            String ipaddr  = part.indexOf(':') == -1 ? null : part.substring(0, part.indexOf(':'));
-            String portnum = part.indexOf(':') == -1 ? part : part.substring(part.indexOf(':') + 1);
+            String ipaddr  = part.indexOf('_') == -1 ? null : part.substring(0, part.indexOf('_'));
+            String portnum = part.indexOf('_') == -1 ? part : part.substring(part.indexOf('_') + 1);
             try {
-                return new Port(this.path + File.separatorChar + part,
-                                ipaddr == null ? null : InetAddress.getByName(ipaddr),
-                                portnum.equals("*") ? 0 : Integer.parseInt(portnum));
+                return Port.newPort(this.path + File.separatorChar + part,
+                                    ipaddr == null ? null : InetAddress.getByName(ipaddr),
+                                    portnum.equals("*") ? 0 : Integer.parseInt(portnum));
             } catch (UnknownHostException e) {  Log.warn(this, "can't resolve host for port directory: " + part);
             } catch (NumberFormatException e) { Log.warn(this, "invalid port directory: " + part);
             } catch (Exception e) {             Log.warn(this, "error instantiating Port: " + part);