com.sun.grizzly.util
Class ClassLoaderUtil

java.lang.Object
  extended by com.sun.grizzly.util.ClassLoaderUtil

public class ClassLoaderUtil
extends Object

Simple ClassLoader utility.

Author:
Jeanfrancois Arcand

Constructor Summary
ClassLoaderUtil()
           
 
Method Summary
static ClassLoader createClassloader(File libDir, ClassLoader cl)
          Deprecated. removal candidate, never used
static URLClassLoader createURLClassLoader(String dirPath)
          Construct a URLClassLoader based on a canonical file location.
static URLClassLoader createURLClassLoader(String location, ClassLoader parent)
          Construct a URLClassLoader based on a canonical file location.
static Object load(String clazzName)
          Load a class using the current {link Thread#getContextClassLoader}
static Object load(String clazzName, ClassLoader classLoader)
          Load a class using the provided ClassLoader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassLoaderUtil

public ClassLoaderUtil()
Method Detail

createClassloader

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 - Directory with jars.
cl - the parent ClassLoader, or null if none.
Returns:
A URLClassLoader that can load classes from a directory that contains jar and zip files.
Throws:
IOException - I/O fail

createURLClassLoader

public static URLClassLoader createURLClassLoader(String dirPath)
                                           throws IOException
Construct a URLClassLoader based on a canonical file location.

Parameters:
dirPath - a canonical path location
Returns:
a URLClassLoader
Throws:
IOException - I/O
MalformedURLException - Invalid URL

createURLClassLoader

public static URLClassLoader createURLClassLoader(String location,
                                                  ClassLoader parent)
                                           throws IOException
Construct a URLClassLoader based on a canonical file location.

Parameters:
location - a canonical path location
parent - ClassLoader to be used as parent for returned one.
Returns:
a URLClassLoader
Throws:
IOException - I/O
MalformedURLException - Invalid URL

load

public static Object load(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 Object load(String clazzName,
                          ClassLoader classLoader)
Load a class using the provided ClassLoader

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


Copyright © 2012 Oracle Corporation. All Rights Reserved.