org.apache.cactus.util
Class ClassLoaderUtils

java.lang.Object
  extended byorg.apache.cactus.util.ClassLoaderUtils

public class ClassLoaderUtils
extends java.lang.Object

Utiliy methods related to class loading in a webapp environment.

Version:
$Id: ClassLoaderUtils.java,v 1.7 2003/05/26 11:45:22 cmlenz Exp $
Author:
Vincent Massol

Constructor Summary
ClassLoaderUtils()
           
 
Method Summary
static java.lang.Class loadClass(java.lang.String theClassName, java.lang.Class theReferrer)
          Try loading a class first by using the context class loader or by using the classloader of the referrer class if the context classloader failed to load the class.
static java.lang.Class loadClassFromContextClassLoader(java.lang.String theClassName)
          Try loading class using the Context class loader.
static java.lang.Class loadClassFromWebappClassLoader(java.lang.String theClassName, java.lang.Class theReferrer)
          Try loading class using the Webapp class loader.
static java.util.ResourceBundle loadPropertyResourceBundle(java.lang.String theName, java.lang.Class theReferrer)
          Try loading a resource bundle from either the context class loader or the
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassLoaderUtils

public ClassLoaderUtils()
Method Detail

loadClass

public static java.lang.Class loadClass(java.lang.String theClassName,
                                        java.lang.Class theReferrer)
                                 throws java.lang.ClassNotFoundException
Try loading a class first by using the context class loader or by using the classloader of the referrer class if the context classloader failed to load the class.

Parameters:
theClassName - the name of the test class
theReferrer - the class will be loaded using the classloader which has loaded this referrer class
Returns:
the class object the test class to call
Throws:
java.lang.ClassNotFoundException - if the class cannot be loaded through either classloader

loadClassFromContextClassLoader

public static java.lang.Class loadClassFromContextClassLoader(java.lang.String theClassName)
                                                       throws java.lang.ClassNotFoundException
Try loading class using the Context class loader.

Parameters:
theClassName - the class to load
Returns:
the Class object for the class to load
Throws:
java.lang.ClassNotFoundException - if the class cannot be loaded through this class loader

loadClassFromWebappClassLoader

public static java.lang.Class loadClassFromWebappClassLoader(java.lang.String theClassName,
                                                             java.lang.Class theReferrer)
                                                      throws java.lang.ClassNotFoundException
Try loading class using the Webapp class loader.

Parameters:
theClassName - the class to load
theReferrer - the class will be loaded using the classloader which has loaded this referrer class
Returns:
the Class object for the class to load
Throws:
java.lang.ClassNotFoundException - if the class cannot be loaded through this class loader

loadPropertyResourceBundle

public static java.util.ResourceBundle loadPropertyResourceBundle(java.lang.String theName,
                                                                  java.lang.Class theReferrer)
Try loading a resource bundle from either the context class loader or the

Parameters:
theName - the resource bundle name
theReferrer - the resource bundle will be loaded using the classloader which has loaded this referrer class
Returns:
the loaded resource bundle


Copyright © 2000-2003 Apache Software Foundation. All Rights Reserved.