-// 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.io.*;
-import org.ibex.util.*;
-import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.net.*;
-import java.util.zip.*;
-
-/** represents a file or directory which is scanned for updates */
-public class Loader extends Watcher {
-
- public /*synchronized*/ void scan() throws IOException { super.scan(); }
-
- private final TreeClassLoader classloader;
- public synchronized ClassLoader getClassLoader() { return classloader; }
- public Loader(String path) { this(path, Loader.class.getClassLoader()); }
- public Loader(String path, ClassLoader parent) { super(path); classloader = new TreeClassLoader(this, parent); }
- public void changed(Watched w) { /*FIXME*/ }
-
- private void fill(Vec vec, File dir) {
- if (!dir.exists()) return;
- if (!dir.isDirectory()) {
- if (!dir.getPath().endsWith(".java")) return;
- vec.addElement(dir.getAbsolutePath());
- } else {
- String[] list = dir.list();
- for(int i=0; i<list.length; i++)
- fill(vec, new File(dir.getAbsolutePath() + File.separatorChar + list[i]));
- }
- }
-
- protected ThreadGroup tg = new ThreadGroup(getAbsolutePath());
- private void nuke() {
- if (tg.activeCount() == 0) return;
- Log.info(this, "killing all threads for: " + path);
- 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, " ");
- }
- }
- }
-
-
-}