Top Description Fields Constructors Methods
org.glassfish.grizzly.http.server.util

public Class ClassLoaderUtil

extends Object
Class Inheritance
Imports
java.io.File, .FilenameFilter, .IOException, java.net.URL, .URLClassLoader, java.security.AccessController, .PrivilegedAction, java.util.logging.Level, .Logger, org.glassfish.grizzly.Grizzly

Simple ClassLoader utility.
Author
Jeanfrancois Arcand

Field Summary

Modifier and TypeField and Description
private static final Logger

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static ClassLoader

Returns:

A URLClassLoader that can load classes from a directory that contains jar and zip files.
createClassloader
(File
Directory with jars.
libDir
,
ClassLoader
the parent ClassLoader, or null if none.
cl
)
Deprecated removal candidate, never used

Create a class loader that can load classes from the specified file directory.

private static URLClassLoader
createClassLoaderWithSecCheck(final URL[] urls, final ClassLoader parent)

public static URLClassLoader

Returns:

a URLClassLoader
createURLClassLoader
(String
a canonical path location
dirPath
)

Construct a URLClassLoader based on a canonical file location.

public static URLClassLoader

Returns:

a URLClassLoader
createURLClassLoader
(String
a canonical path location
location
,
ClassLoader
ClassLoader to be used as parent for returned one.
parent
)

Construct a URLClassLoader based on a canonical file location.

public static Object

Returns:

an instance of clazzname
load
(String
The name of the class you want to load.
clazzName
)

Load a class using the current {link Thread#getContextClassLoader}

public static Object

Returns:

an instance of clazzname
load
(String
The name of the class you want to load.
clazzName
,
ClassLoader
A classloader to use for loading a class.
classLoader
)

Load a class using the provided ClassLoader

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LOGGERback to summary
private static final Logger LOGGER

Constructor Detail

ClassLoaderUtilback to summary
public ClassLoaderUtil()

Method Detail

createClassloaderback to summary
public static ClassLoader createClassloader(File libDir, ClassLoader cl) throws IOException

Deprecated

removal candidate, never used

Create a class loader that can load classes from the specified file directory. The file directory must contains .jar or .zip

Parameters
libDir:File

Directory with jars.

cl:ClassLoader

the parent ClassLoader, or null if none.

Returns:ClassLoader

A URLClassLoader that can load classes from a directory that contains jar and zip files.

Annotations
@Deprecated
Exceptions
IOException:
I/O fail
createClassLoaderWithSecCheckback to summary
private static URLClassLoader createClassLoaderWithSecCheck(final URL[] urls, final ClassLoader parent)
createURLClassLoaderback to summary
public static URLClassLoader createURLClassLoader(String dirPath) throws IOException

Construct a URLClassLoader based on a canonical file location.

Parameters
dirPath:String

a canonical path location

Returns:URLClassLoader

a URLClassLoader

Exceptions
IOException:
I/O
MalformedURLException:
Invalid URL
createURLClassLoaderback to summary
public static URLClassLoader createURLClassLoader(String location, ClassLoader parent) throws IOException

Construct a URLClassLoader based on a canonical file location.

Parameters
location:String

a canonical path location

parent:ClassLoader

ClassLoader to be used as parent for returned one.

Returns:URLClassLoader

a URLClassLoader

Exceptions
IOException:
I/O
MalformedURLException:
Invalid URL
loadback to summary
public static Object load(String clazzName)

Load a class using the current {link Thread#getContextClassLoader}

Parameters
clazzName:String

The name of the class you want to load.

Returns:Object

an instance of clazzname

loadback to summary
public static Object load(String clazzName, ClassLoader classLoader)

Load a class using the provided ClassLoader

Parameters
clazzName:String

The name of the class you want to load.

classLoader:ClassLoader

A classloader to use for loading a class.

Returns:Object

an instance of clazzname