cleanup
[org.ibex.jinetd.git] / src / org / ibex / jinetd / TreeClassLoader.java
index e9f901f..d7b4f5e 100644 (file)
@@ -23,6 +23,8 @@ public class TreeClassLoader extends URLClassLoader {
         this.lib = new File(root.getAbsolutePath() + File.separatorChar + "lib");
     }
 
+    public Enumeration getLoadedClassNames() { return cache.keys(); }
+
     // Classloading //////////////////////////////////////////////////////////////////////////////
 
     public URL[] getURLs() {
@@ -112,4 +114,32 @@ public class TreeClassLoader extends URLClassLoader {
         return null;
     }
 
+    // Experimental //////////////////////////////////////////////////////////////////////////////
+
+    protected ThreadGroup tg = null;
+    private void nuke() {
+        if (tg.activeCount() == 0) return;
+        Log.info(this, "killing all threads for: " + root.getAbsolutePath());
+        Log.info(this, "   thread count before interrupt: " + tg.activeCount());
+        tg.interrupt();
+        try { Thread.sleep(3000); } catch (Exception e) { Log.error(this, e); }
+        Log.info(this, "   thread count before kill: " + tg.activeCount());
+        Thread[] all = new Thread[tg.activeCount()];
+        tg.enumerate(all, true);
+        for(int i=0; i<all.length; i++) Stream.kill(all[i]);
+        try { Thread.sleep(3000); } catch (Exception e) { Log.error(this, e); }
+        Log.info(this, "   thread count after kill: " + tg.activeCount());
+        if (tg.activeCount() > 0) {
+            Log.warn(this, "    annoying threads:");
+            Thread[] annoying = new Thread[tg.activeCount()];
+            tg.enumerate(annoying, true);
+            for(int i=0; i<annoying.length; i++) {
+                Log.warn(this, "      " + annoying[i]);
+                StackTraceElement[] stack = annoying[i].getStackTrace();
+                for(int j=0; j<stack.length; j++) Log.warn(this, "        " + stack[j]);
+                Log.warn(this, " ");
+            }
+        }
+    }
+
 }