Class ClassLoaderUtil
- java.lang.Object
-
- org.glassfish.grizzly.http.server.util.ClassLoaderUtil
-
public class ClassLoaderUtil extends java.lang.ObjectSimpleClassLoaderutility.- Author:
- Jeanfrancois Arcand
-
-
Constructor Summary
Constructors Constructor Description ClassLoaderUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static java.lang.ClassLoadercreateClassloader(java.io.File libDir, java.lang.ClassLoader cl)Deprecated.removal candidate, never usedstatic java.net.URLClassLoadercreateURLClassLoader(java.lang.String dirPath)Construct aURLClassLoaderbased on a canonical file location.static java.net.URLClassLoadercreateURLClassLoader(java.lang.String location, java.lang.ClassLoader parent)Construct aURLClassLoaderbased on a canonical file location.static java.lang.Objectload(java.lang.String clazzName)Load a class using the current {link Thread#getContextClassLoader}static java.lang.Objectload(java.lang.String clazzName, java.lang.ClassLoader classLoader)Load a class using the providedClassLoader
-
-
-
Method Detail
-
createClassloader
@Deprecated public static java.lang.ClassLoader createClassloader(java.io.File libDir, java.lang.ClassLoader cl) throws java.io.IOExceptionDeprecated.removal candidate, never usedCreate a class loader that can load classes from the specified file directory. The file directory must contains .jar or .zip- Parameters:
libDir- Directory with jars.cl- the parentClassLoader, or null if none.- Returns:
- A
URLClassLoaderthat can load classes from a directory that contains jar and zip files. - Throws:
java.io.IOException- I/O fail
-
createURLClassLoader
public static java.net.URLClassLoader createURLClassLoader(java.lang.String dirPath) throws java.io.IOExceptionConstruct aURLClassLoaderbased on a canonical file location.- Parameters:
dirPath- a canonical path location- Returns:
- a
URLClassLoader - Throws:
java.io.IOException- I/Ojava.net.MalformedURLException- Invalid URL
-
createURLClassLoader
public static java.net.URLClassLoader createURLClassLoader(java.lang.String location, java.lang.ClassLoader parent) throws java.io.IOExceptionConstruct aURLClassLoaderbased on a canonical file location.- Parameters:
location- a canonical path locationparent-ClassLoaderto be used as parent for returned one.- Returns:
- a
URLClassLoader - Throws:
java.io.IOException- I/Ojava.net.MalformedURLException- Invalid URL
-
load
public static java.lang.Object load(java.lang.String clazzName)
Load a class using the current {link Thread#getContextClassLoader}- Parameters:
clazzName- The name of the class you want to load.- Returns:
- an instance of clazzname
-
load
public static java.lang.Object load(java.lang.String clazzName, java.lang.ClassLoader classLoader)Load a class using the providedClassLoader- Parameters:
clazzName- The name of the class you want to load.classLoader- A classloader to use for loading a class.- Returns:
- an instance of clazzname
-
-