Class ClassLoaderUtil
java.lang.Object
org.glassfish.grizzly.http.server.util.ClassLoaderUtil
Simple
ClassLoader utility.- Author:
- Jeanfrancois Arcand
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ClassLoadercreateClassloader(File libDir, ClassLoader cl) Deprecated.removal candidate, never usedstatic URLClassLoadercreateURLClassLoader(String dirPath) Construct aURLClassLoaderbased on a canonical file location.static URLClassLoadercreateURLClassLoader(String location, ClassLoader parent) Construct aURLClassLoaderbased on a canonical file location.static ObjectLoad a class using the current {link Thread#getContextClassLoader}static Objectload(String clazzName, ClassLoader classLoader) Load a class using the providedClassLoader
-
Constructor Details
-
ClassLoaderUtil
public ClassLoaderUtil()
-
-
Method Details
-
createClassloader
@Deprecated public static ClassLoader createClassloader(File libDir, ClassLoader cl) throws IOException Deprecated.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:
IOException- I/O fail
-
createURLClassLoader
Construct aURLClassLoaderbased on a canonical file location.- Parameters:
dirPath- a canonical path location- Returns:
- a
URLClassLoader - Throws:
IOException- I/OMalformedURLException- Invalid URL
-
createURLClassLoader
public static URLClassLoader createURLClassLoader(String location, ClassLoader parent) throws IOException Construct aURLClassLoaderbased on a canonical file location.- Parameters:
location- a canonical path locationparent-ClassLoaderto be used as parent for returned one.- Returns:
- a
URLClassLoader - Throws:
IOException- I/OMalformedURLException- Invalid URL
-
load
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
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
-