public abstract class ClasspathHelper extends Object
Modifier and Type | Field and Description |
---|---|
static ClassLoader[] |
defaultClassLoaders |
Constructor and Description |
---|
ClasspathHelper() |
Modifier and Type | Method and Description |
---|---|
static ClassLoader[] |
classLoaders(ClassLoader... classLoaders)
returns given classLoaders, if not null,
otherwise defaults to both
getContextClassLoader() and getStaticClassLoader() |
static URL |
forClass(Class<?> aClass,
ClassLoader... classLoaders)
returns the url that contains the given class, using
ClassLoader.getResource(String) |
static Set<URL> |
forClassLoader(ClassLoader... classLoaders)
returns urls using
URLClassLoader.getURLs() up the classloader parent hierarchy |
static Set<URL> |
forJavaClassPath()
returns urls using
java.class.path system property |
static Set<URL> |
forManifest()
return urls that are in the current class path.
|
static Set<URL> |
forManifest(Iterable<URL> urls)
get the urls that are specified in the manifest of the given urls.
|
static Set<URL> |
forManifest(URL url)
get the urls that are specified in the manifest of the given url for a jar file.
|
static Set<URL> |
forPackage(String name,
ClassLoader... classLoaders)
returns urls with resources of package starting with given name, using
ClassLoader.getResources(String) |
static URL |
forWebInfClasses(javax.servlet.ServletContext servletContext)
returns url using
ServletContext in resource path WEB-INF/classes |
static Set<URL> |
forWebInfLib(javax.servlet.ServletContext servletContext)
returns urls using
ServletContext in resource path WEB-INF/lib |
static ClassLoader |
getContextClassLoader()
returns
Thread.currentThread().getContextClassLoader() |
static ClassLoader |
getStaticClassLoader()
returns
Reflections.class.getClassLoader() |
public static ClassLoader[] defaultClassLoaders
public static ClassLoader getContextClassLoader()
Thread.currentThread().getContextClassLoader()
public static ClassLoader getStaticClassLoader()
Reflections.class.getClassLoader()
public static ClassLoader[] classLoaders(ClassLoader... classLoaders)
getContextClassLoader()
and getStaticClassLoader()
public static Set<URL> forPackage(String name, ClassLoader... classLoaders)
ClassLoader.getResources(String)
that is, forPackage("org.reflections") effectively returns urls from classpath with packages starting with org.reflections
if optional ClassLoader
s are not specified, then both getContextClassLoader()
and getStaticClassLoader()
are used for ClassLoader.getResources(String)
public static URL forClass(Class<?> aClass, ClassLoader... classLoaders)
ClassLoader.getResource(String)
if optional ClassLoader
s are not specified, then either getContextClassLoader()
or getStaticClassLoader()
are used for ClassLoader.getResources(String)
public static Set<URL> forClassLoader(ClassLoader... classLoaders)
URLClassLoader.getURLs()
up the classloader parent hierarchy
if optional ClassLoader
s are not specified, then both getContextClassLoader()
and getStaticClassLoader()
are used for ClassLoader.getResources(String)
public static Set<URL> forJavaClassPath()
java.class.path
system propertypublic static Set<URL> forWebInfLib(javax.servlet.ServletContext servletContext)
ServletContext
in resource path WEB-INF/libpublic static URL forWebInfClasses(javax.servlet.ServletContext servletContext)
ServletContext
in resource path WEB-INF/classespublic static Set<URL> forManifest()
public static Set<URL> forManifest(URL url)
Copyright © 2013-2015 JBoss, a division of Red Hat. All Rights Reserved.