org.globus.util
Class ClassLoaderUtils

java.lang.Object
  extended byorg.globus.util.ClassLoaderUtils

public class ClassLoaderUtils
extends Object

Various classloader utils. Extends the standard ways of loading classes or resources with a fallback mechanism to the thread context classloader.


Constructor Summary
ClassLoaderUtils()
           
 
Method Summary
static Class forName(String name)
          Loads a specified class.
static Class[] getClassContext()
          Returns the current execution stack as an array of classes.
static Class getClassContextAt(int i)
          Returns a class at specified depth of the current execution stack.
static ClassLoader getClassLoaderContextAt(int i)
          Returns a classloader at specified depth of the current execution stack.
static InputStream getResourceAsStream(String name)
          Gets an InputStream to a resource of a specified name.
 
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

getClassContext

public static Class[] getClassContext()
Returns the current execution stack as an array of classes.

The length of the array is the number of methods on the execution stack. The element at index 0 is the class of the currently executing method, the element at index 1 is the class of that method's caller, and so on.

Returns:
the execution stack.

getClassContextAt

public static Class getClassContextAt(int i)
Returns a class at specified depth of the current execution stack.

Returns:
the class at the specified depth of the current execution stack. Migth return null if depth is out of range.

getClassLoaderContextAt

public static ClassLoader getClassLoaderContextAt(int i)
Returns a classloader at specified depth of the current execution stack.

Returns:
the classloader at the specified depth of the current execution stack. Migth return null if depth is out of range.

getResourceAsStream

public static InputStream getResourceAsStream(String name)
Gets an InputStream to a resource of a specified name. First, the caller's classloader is used to load the resource and if it fails the thread's context classloader is used to load the resource.


forName

public static Class forName(String name)
                     throws ClassNotFoundException
Loads a specified class. First, the caller's classloader is used to load the class and if it fails the thread's context classloader is used to load the specified class.

Throws:
ClassNotFoundException