public abstract class ReflectionsWorkaroundClasspathHelper extends Object
ClasspathHelper.
This workaround expires once https://github.com/ronmamo/reflections/pull/118 is fixed.| Constructor and Description |
|---|
ReflectionsWorkaroundClasspathHelper() |
| Modifier and Type | Method and Description |
|---|---|
static ClassLoader[] |
classLoaders(ClassLoader... classLoaders)
Returns an array of class Loaders initialized from the specified array.
|
static String |
cleanPath(URL url)
Cleans the URL.
|
static ClassLoader |
contextClassLoader()
Gets the current thread context class loader.
|
static URL |
forClass(Class<?> aClass,
ClassLoader... classLoaders)
Returns the URL that contains a
Class. |
static Collection<URL> |
forClassLoader()
Returns a distinct collection of URLs based on URLs derived from class loaders.
|
static Collection<URL> |
forClassLoader(ClassLoader... classLoaders)
Returns a distinct collection of URLs based on URLs derived from class loaders.
|
static Collection<URL> |
forJavaClassPath()
Returns a distinct collection of URLs based on the
java.class.path system property. |
static Collection<URL> |
forPackage(String name,
ClassLoader... classLoaders)
Returns a distinct collection of URLs based on a package name.
|
static Collection<URL> |
forResource(String resourceName,
ClassLoader... classLoaders)
Returns a distinct collection of URLs based on a resource.
|
static ClassLoader |
staticClassLoader()
Gets the class loader of this library.
|
public ReflectionsWorkaroundClasspathHelper()
public static ClassLoader contextClassLoader()
Thread.currentThread().getContextClassLoader().public static ClassLoader staticClassLoader()
Reflections.class.getClassLoader().public static ClassLoader[] classLoaders(ClassLoader... classLoaders)
If the input is null or empty, it defaults to both contextClassLoader() and staticClassLoader()
public static Collection<URL> forPackage(String name, ClassLoader... classLoaders)
This searches for the package name as a resource, using ClassLoader.getResources(String).
For example, forPackage(org.reflections) effectively returns URLs from the
classpath containing packages starting with org.reflections.
If the optional ClassLoaders are not specified, then both contextClassLoader()
and staticClassLoader() are used for ClassLoader.getResources(String).
The returned URLs retains the order of the given classLoaders.
public static Collection<URL> forResource(String resourceName, ClassLoader... classLoaders)
This searches for the resource name, using ClassLoader.getResources(String).
For example, forResource(test.properties) effectively returns URLs from the
classpath containing files of that name.
If the optional ClassLoaders are not specified, then both contextClassLoader()
and staticClassLoader() are used for ClassLoader.getResources(String).
The returned URLs retains the order of the given classLoaders.
public static URL forClass(Class<?> aClass, ClassLoader... classLoaders)
Class.
This searches for the class using ClassLoader.getResource(String).
If the optional ClassLoaders are not specified, then both contextClassLoader()
and staticClassLoader() are used for ClassLoader.getResources(String).
public static Collection<URL> forClassLoader()
This finds the URLs using URLClassLoader.getURLs() using both
contextClassLoader() and staticClassLoader().
The returned URLs retains the order of the given classLoaders.
public static Collection<URL> forClassLoader(ClassLoader... classLoaders)
This finds the URLs using URLClassLoader.getURLs() using the specified
class loader, searching up the parent hierarchy.
If the optional ClassLoaders are not specified, then both contextClassLoader()
and staticClassLoader() are used for ClassLoader.getResources(String).
The returned URLs retains the order of the given classLoaders.
public static Collection<URL> forJavaClassPath()
java.class.path system property.
This finds the URLs using the java.class.path system property.
The returned collection of URLs retains the classpath order.
Copyright © 2006–2019 JBoss by Red Hat. All rights reserved.