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)
          Create a class loader that can load classes from the specified file directory.
static URLClassLoader createURLClassLoader(String dirPath)
          Construct a URLClassloader based on a canonial 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 final ClassLoader createClassloader(File libDir,
                                                  ClassLoader cl)
                                           throws IOException
Create a class loader that can load classes from the specified file directory. The file directory must contains .jar ot .zip

Parameters:
file - a directory
ClassLoader - the parent classloader, or null if none.
Returns:
A Classloader that can load classes from a directory that contains jar and zip files.
Throws:
IOException

createURLClassLoader

public static URLClassLoader createURLClassLoader(String dirPath)
                                           throws MalformedURLException,
                                                  IOException
Construct a URLClassloader based on a canonial file location.

Parameters:
dirPath - a canonial path location
Returns:
a URLClassLoader
Throws:
MalformedURLException
IOException

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 © 2009 SUN Microsystems. All Rights Reserved.