@Test public void testScanPlugins() throws Exception { ClassPathAnnotationScanner scanner = new ClassPathAnnotationScanner(Plugin.class.getName(), new ClassPathScanner()); assertArrayEquals("Plugin discovered", new String[]{SimplePlugin.class.getName()}, scanner.scanPlugins(getClass().getClassLoader(), "org/hotswap/agent/testData").toArray()); }
public List<String> scanPlugins(ClassLoader classLoader, String path) throws IOException { final List<String> files = new LinkedList<>(); scanner.scan(classLoader, path, new ScannerVisitor() { @Override public void visit(InputStream file) throws IOException { ClassFile cf; try { DataInputStream dstream = new DataInputStream(file); cf = new ClassFile(dstream); } catch (IOException e) { throw new IOException("Stream not a valid classFile", e); } if (hasAnnotation(cf)) files.add(cf.getName()); } }); return files; }
ClassPathAnnotationScanner { public List<String> scanPlugins(ClassLoader classLoader, String path) throws IOException { final List<String> files = new LinkedList<>(); scanner.scan(classLoader, path, new ScannerVisitor() { @Override public void visit(InputStream file) throws IOException { ClassFile cf; try { DataInputStream dstream = new DataInputStream(file); cf = new ClassFile(dstream); } catch (IOException e) { throw new IOException("Stream not a valid classFile", e); } if (hasAnnotation(cf)) files.add(cf.getName()); } }); return files; } }
ClassPathAnnotationScanner { public List<String> scanPlugins(ClassLoader classLoader, String path) throws IOException { final List<String> files = new LinkedList<>(); scanner.scan(classLoader, path, new ScannerVisitor() { @Override public void visit(InputStream file) throws IOException { ClassFile cf; try { DataInputStream dstream = new DataInputStream(file); cf = new ClassFile(dstream); } catch (IOException e) { throw new IOException("Stream not a valid classFile", e); } if (hasAnnotation(cf)) files.add(cf.getName()); } }); return files; } ClassPathAnnotationScanner(String annotation, Scanner scanner); }
ClassPathAnnotationScanner { public List<String> scanPlugins(ClassLoader classLoader, String path) throws IOException { final List<String> files = new LinkedList<>(); scanner.scan(classLoader, path, new ScannerVisitor() { @Override public void visit(InputStream file) throws IOException { ClassFile cf; try { DataInputStream dstream = new DataInputStream(file); cf = new ClassFile(dstream); } catch (IOException e) { throw new IOException("Stream not a valid classFile", e); } if (hasAnnotation(cf)) files.add(cf.getName()); } }); return files; } ClassPathAnnotationScanner(String annotation, Scanner scanner); List<String> scanPlugins(ClassLoader classLoader, String path); }
ClassPathAnnotationScanner { public List<String> scanPlugins(ClassLoader classLoader, String path) throws IOException { final List<String> files = new LinkedList<>(); scanner.scan(classLoader, path, new ScannerVisitor() { @Override public void visit(InputStream file) throws IOException { ClassFile cf; try { DataInputStream dstream = new DataInputStream(file); cf = new ClassFile(dstream); } catch (IOException e) { throw new IOException("Stream not a valid classFile", e); } if (hasAnnotation(cf)) files.add(cf.getName()); } }); return files; } ClassPathAnnotationScanner(String annotation, Scanner scanner); List<String> scanPlugins(ClassLoader classLoader, String path);  }