- fis = new FileInputStream(f);
- ZipInputStream zis = new ZipInputStream(fis);
- for(ZipEntry ze = zis.getNextEntry(); ze != null; ze = zis.getNextEntry()) {
- String name = ze.getName();
- if (name.endsWith(".class"))
- if (dispatch(conn, name.substring(0, name.length() - ".class".length()).replace('/', '.')))
- return true;
- }
- } finally { if (fis != null) fis.close(); }
- }
- if (check(conn, new File(getAbsolutePath() + File.separatorChar + "BIN"))) return true;
- return false;
- }
-
- boolean check(Connection conn, File f) throws Exception {
- if (!f.exists()) return false;
- if (!f.isDirectory()) {
- if (!f.getAbsolutePath().endsWith(".class")) return false;
- String name = f.getAbsolutePath().substring(getAbsolutePath().length() + 5);
- name = name.substring(0, name.length() - ".class".length()).replace(File.separatorChar, '.');
- if (dispatch(conn, name)) return true;
- } else {
- String[] list = f.list();
- for(int i=0; i<list.length; i++)
- if (check(conn, new File(f.getAbsolutePath() + File.separatorChar + list[i])))
- return true;
- }
- return false;
- }
-
- boolean dispatch(final Connection conn, String name) throws Exception {
- try {
- final ClassLoader cl = getClassLoader();
- final Class c = cl.loadClass(name);
- if (c == null) return false;
- if (!(Listener.class.isAssignableFrom(c) && c != Listener.class)) return false;
- Log.info(this, "dispatching connection on port " + port + " to " + c.getName());
- new Thread(tg, new Runnable() { public void run() {