BaseLoader { public <T> Collection<T> loadFromDir(File file, Class<T> type) { ArrayList<T> list = new ArrayList<>(); try { List<Class<T>> implementationClasses = getInterfaceImplementations(type, file); for (Class<?> class1 : implementationClasses) { try { T classInstance = (T) class1.newInstance(); list.add(classInstance); } catch (Throwable e) { LOGGER.error(String.format("Error creating class %s from file %s: %s", class1.getName(), file, e.getMessage())); } } } catch (Throwable e) { LOGGER.error(String.format("Error loading class type %s from file %s: %s", type, file, e.getMessage())); } return list; }  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 testLoadFromDir() throws URISyntaxException { Collection<LogFilter> load = baseLoader.loadFromDir(getFile("plugins/filters/"), LogFilter.class); AssertJUnit.assertEquals(1, load.size()); }