Java Code Examples for org.reflections.util.ClasspathHelper#forClassLoader()

The following examples show how to use org.reflections.util.ClasspathHelper#forClassLoader() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Parser.java    From Java2PlantUML with Apache License 2.0 5 votes vote down vote up
private static Collection<URL> getUrls(List<ClassLoader> classLoadersList) {
    classLoadersList.add(ClasspathHelper.contextClassLoader());
    classLoadersList.add(ClasspathHelper.staticClassLoader());
    Collection<URL> urls = ClasspathHelper.forClassLoader(classLoadersList.toArray(new ClassLoader[0]));
    CLASS_LOADER = new URLClassLoader(urls.toArray(new URL[0]));
    return urls;
}
 
Example 2
Source File: ExtensionRegistry.java    From butterfly with MIT License 4 votes vote down vote up
private Set<Class<? extends Extension>>  findExtensionClasses() {
    final Collection<URL> systemPropertyURLs = ClasspathHelper.forJavaClassPath();
    final Collection<URL> classLoaderURLs = ClasspathHelper.forClassLoader();

    Set<URL> classpathURLs = new HashSet<>();

    copyValidClasspathEntries(systemPropertyURLs, classpathURLs);
    copyValidClasspathEntries(classLoaderURLs, classpathURLs);

    logger.debug("Classpath URLs to be scanned: " + classpathURLs);

    Reflections reflections = new Reflections(classpathURLs, new SubTypesScanner());

    TreeSet<Class<? extends Extension>> extensionClasses = new TreeSet<>(Comparator.comparing(c -> c.getName()));
    extensionClasses.addAll(reflections.getSubTypesOf(Extension.class));

    return extensionClasses;
}