public final class ClassLoaderUtils extends Object
| Modifier and Type | Method and Description | 
|---|---|
| static ClassLoader | getContextClassLoader()Dynamically accesses the current context class loader. | 
| static URL | getResource(String name)Locates the resource with the specified name. | 
| static URL | getResource(String name,
           ClassLoader callerClassLoader)Locates the resource with the specified name. | 
| static InputStream | getResourceAsStream(String name)Locates the stream resource with the specified name. | 
| static InputStream | getResourceAsStream(String name,
                   ClassLoader callerClassLoader)Locates the resource stream with the specified name. | 
| static <T> T | getService(Class<T> service)Instantiate the first registered services from a file in /META-INF/services. | 
| static <T> T | getService(String service)Instantiate the first registered services from a file in /META-INF/services. | 
| static <T> List<T> | getServices(Class<T> service)Instantiate all available services from a file in /META-INF/services. | 
| static <T> List<T> | getServices(String service)Instantiate all available services from a file in /META-INF/services. | 
| static Class<?> | loadClass(String name)Loads the class with the specified name. | 
| static Class<?> | loadClass(String name,
         ClassLoader callerClassLoader)Loads the class with the specified name. | 
public static Class<?> loadClass(String name) throws ClassNotFoundException
name - the name of the classClass objectClassNotFoundException - if the class was not foundpublic static URL getResource(String name)
name - the name of the resourceURL objectpublic static InputStream getResourceAsStream(String name)
name - the name of the resourceInputStream objectpublic static Class<?> loadClass(String name, ClassLoader callerClassLoader) throws ClassNotFoundException
name - the name of the classcallerClassLoader - the calling class loader contextClass objectClassNotFoundException - if the class was not foundpublic static URL getResource(String name, ClassLoader callerClassLoader)
name - the name of the resourcecallerClassLoader - the calling class loader contextURL objectpublic static InputStream getResourceAsStream(String name, ClassLoader callerClassLoader)
name - the name of the resourcecallerClassLoader - the calling class loader contextInputStream objectpublic static ClassLoader getContextClassLoader()
public static <T> T getService(Class<T> service)
service - the classname of the abstract service class.
 eg: javax.servlet.FiltergetService(String), 
getServices(Class), 
getServices(String)public static <T> T getService(String service)
service - the classname of the abstract service class.
 eg: javax.servlet.FiltergetService(Class), 
getServices(String), 
getServices(Class)public static <T> List<T> getServices(Class<T> service)
public static <T> List<T> getServices(String service)
The following is an excerpt from the JAR File specification: A service provider identifies itself by placing a provider-configuration file in the resource directory META-INF/services. The file's name should consist of the fully-qualified name of the abstract service class. The file should contain a newline-separated list of unique concrete provider-class names. Space and tab characters, as well as blank lines, are ignored. The comment character is '#' (0x23); on each line all characters following the first comment character are ignored. The file must be encoded in UTF-8.
service - the classname of the abstract service class.
 eg: javax.servlet.FiltergetServices(Class), 
getService(Class), 
getService(String)Copyright © 2001-2017 The Apache Software Foundation. All Rights Reserved.