public List<ClasspathResource> scan(ClassLoader loader, boolean triggerNotification) { if (!URLClassLoader.class.isInstance(loader)) { throw new RuntimeException("Attempted to scan without using a URL Class Loader"); } Classpath cpResources = resources.get((URLClassLoader)loader); if (cpResources == null) { Map<String, ClasspathResource> fileMap = new HashMap<>(); URLClassLoader cp = (URLClassLoader)loader; ArrayList<ClasspathResource> myResources = new ArrayList<>(); for(URL url : cp.getURLs()) { String path = url.toString(); if (path.startsWith(JAR_PREFIX)) { processJarResource(path, url, fileMap, myResources); } else if (path.startsWith(FILE_PREFIX)) { processFileResource(path, url, fileMap, myResources); } } cpResources = new Classpath(myResources); resources.put(cp, cpResources); } if (triggerNotification) { cpResources.triggerNotifications(); } return cpResources.classpaths; }