Package org.globus.util
Class ClassLoaderUtils
- java.lang.Object
-
- org.globus.util.ClassLoaderUtils
-
public class ClassLoaderUtils extends java.lang.ObjectVarious classloader utils. Extends the standard ways of loading classes or resources with a fallback mechanism to the thread context classloader.
-
-
Constructor Summary
Constructors Constructor Description ClassLoaderUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.ClassforName(java.lang.String name)Loads a specified class.static java.lang.Class[]getClassContext()Returns the current execution stack as an array of classes.static java.lang.ClassgetClassContextAt(int i)Returns a class at specified depth of the current execution stack.static java.lang.ClassLoadergetClassLoaderContextAt(int i)Returns a classloader at specified depth of the current execution stack.static java.io.InputStreamgetResourceAsStream(java.lang.String name)Gets an InputStream to a resource of a specified name.static java.lang.Class<?>loadClass(java.lang.String className, java.lang.Class<?> callingClass)
-
-
-
Method Detail
-
getClassContext
public static java.lang.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
0is the class of the currently executing method, the element at index1is the class of that method's caller, and so on.- Returns:
- the execution stack.
-
getClassContextAt
public static java.lang.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 java.lang.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 java.io.InputStream getResourceAsStream(java.lang.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 java.lang.Class forName(java.lang.String name) throws java.lang.ClassNotFoundExceptionLoads 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:
java.lang.ClassNotFoundException
-
loadClass
public static java.lang.Class<?> loadClass(java.lang.String className, java.lang.Class<?> callingClass) throws java.lang.ClassNotFoundException- Throws:
java.lang.ClassNotFoundException
-
-