public JawrConfig() { resourceScanListener = new JawrResourceScanListener(); ClasspathScanner.getInstance().registerResourceScanner(resourceScanListener); }
@Override public Properties getConfigProperties() { if (Flags.DEVMODE.on() || !scanned) { ClasspathScanner.getInstance().scan(getClass().getClassLoader(), true); } return jawrProperties; }
public static void resetScannerForTesting() { globalScanner = new ClasspathScanner(); releaseAllResources(); }
ClasspathScanner scanner = ClasspathScanner.getInstance(); scanner.registerResourceScanner(listener); scanner.scan(context.getClassLoader());
public List<ClasspathResource> scan(ClassLoader loader) { return scan(loader, true); }
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; }
private void processFileResource(String path, URL url, Map<String, ClasspathResource> fileMap, List<ClasspathResource> myResources) { path = path.substring(FILE_PREFIX.length()); // does it already exist in the map? if so, stop processing and ignore ClasspathResource resource = fileMap.get(path); if (resource == null) { foundJar(path, url, fileMap, null, myResources); } }
ClasspathScanner scanner = ClasspathScanner.getInstance(); scanner.registerResourceScanner(listener); scanner.scan(context.getClassLoader());
private void processJarResource(String path, URL url, Map<String, ClasspathResource> fileMap, List<ClasspathResource> myResources) { path = path.substring(JAR_PREFIX.length() + FILE_PREFIX.length()); String offset = null; int offsetPos = path.indexOf('!'); if (offsetPos != -1) { offset = path.substring(offsetPos + 1); path = path.substring(0, offsetPos); } // does it already exist in the map? if so, stop processing and ignore ClasspathResource resource = fileMap.get(path); if (resource != null) { if (offset != null) { resource.addJarOffset(offset, url); } } else { foundJar(path, url, fileMap, offset, myResources); } }
log.info("Registering scanner for uncompiled SCSS directories"); ClasspathScanner.getInstance().registerResourceScanner(new ResourceScanListener() { @Override public List<ScanResource> resource(List<ScanResource> scanResources) throws Exception {