BaseLoader { public <T> Collection<T> load(File dir, Class<T> type) { Set<T> logImporters = new HashSet<>(); if (!dir.exists()) { return new ArrayList<>(); } File[] files = dir.listFiles(pathname -> { return pathname.getName().endsWith(".jar") || pathname.getName().endsWith(".zip"); }); logImporters.addAll(loadFromDir(dir, type)); for (File file : files) { logImporters.addAll(loadFromJar(file, type)); } return logImporters; }  Collection<T> load(File dir, Class<T> type); Collection<T> loadFromDir(File file, Class<T> type); Collection<T> loadFromJar(File file, Class<T> type); List<Class<T>> getInterfaceImplementations(Class<T> interfaceClass, File f); List<String> getClassesFromDir(File dir); List<String> getClassesFromJar(File jarFile); static final Logger LOGGER; }
@Test(enabled = false) public void testLoad() throws URISyntaxException { File dir = getFile("plugins/filters/"); Collection<LogFilter> load = baseLoader.load(dir, LogFilter.class); AssertJUnit.assertEquals(2, load.size()); }