Errai 3.0.1-SNAPSHOT

org.jboss.errai.reflections.util
Class ClasspathHelper

java.lang.Object
  extended by org.jboss.errai.reflections.util.ClasspathHelper

public abstract class ClasspathHelper
extends Object

Some classpath convenient methods


Field Summary
static ClassLoader[] defaultClassLoaders
           
 
Constructor Summary
ClasspathHelper()
           
 
Method Summary
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()
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultClassLoaders

public static ClassLoader[] defaultClassLoaders
Constructor Detail

ClasspathHelper

public ClasspathHelper()
Method Detail

getContextClassLoader

public static ClassLoader getContextClassLoader()
returns Thread.currentThread().getContextClassLoader()


getStaticClassLoader

public static ClassLoader getStaticClassLoader()
returns Reflections.class.getClassLoader()


classLoaders

public static ClassLoader[] classLoaders(ClassLoader... classLoaders)
returns given classLoaders, if not null, otherwise defaults to both getContextClassLoader() and getStaticClassLoader()


forPackage

public static Set<URL> forPackage(String name,
                                  ClassLoader... classLoaders)
returns urls with resources of package starting with given name, using ClassLoader.getResources(String)

that is, forPackage("org.reflections") effectively returns urls from classpath with packages starting with org.reflections

if optional ClassLoaders are not specified, then both getContextClassLoader() and getStaticClassLoader() are used for ClassLoader.getResources(String)


forClass

public static URL forClass(Class<?> aClass,
                           ClassLoader... classLoaders)
returns the url that contains the given class, using ClassLoader.getResource(String)

if optional ClassLoaders are not specified, then either getContextClassLoader() or getStaticClassLoader() are used for ClassLoader.getResources(String)


forClassLoader

public static Set<URL> forClassLoader(ClassLoader... classLoaders)
returns urls using URLClassLoader.getURLs() up the classloader parent hierarchy

if optional ClassLoaders are not specified, then both getContextClassLoader() and getStaticClassLoader() are used for ClassLoader.getResources(String)


forJavaClassPath

public static Set<URL> forJavaClassPath()
returns urls using java.class.path system property


forWebInfLib

public static Set<URL> forWebInfLib(javax.servlet.ServletContext servletContext)
returns urls using ServletContext in resource path WEB-INF/lib


forWebInfClasses

public static URL forWebInfClasses(javax.servlet.ServletContext servletContext)
returns url using ServletContext in resource path WEB-INF/classes


forManifest

public static Set<URL> forManifest()
return urls that are in the current class path. attempts to load the jar manifest, if any, and adds to the result any dependencies it finds.


forManifest

public static Set<URL> forManifest(URL url)
get the urls that are specified in the manifest of the given url for a jar file. attempts to load the jar manifest, if any, and adds to the result any dependencies it finds.


forManifest

public static Set<URL> forManifest(Iterable<URL> urls)
get the urls that are specified in the manifest of the given urls. attempts to load the jar manifest, if any, and adds to the result any dependencies it finds.


Errai 3.0.1-SNAPSHOT

Copyright © 2013-2014 JBoss, a division of Red Hat. All Rights Reserved.