Class ClassLoaderUtils
java.lang.Object
org.globus.util.ClassLoaderUtils
Various classloader utils. Extends the standard ways of loading classes or
resources with a fallback mechanism to the thread context classloader.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ClassLoads a specified class.static Class[]Returns the current execution stack as an array of classes.static ClassgetClassContextAt(int i) Returns a class at specified depth of the current execution stack.static ClassLoadergetClassLoaderContextAt(int i) Returns a classloader at specified depth of the current execution stack.static InputStreamgetResourceAsStream(String name) Gets an InputStream to a resource of a specified name.static Class<?> private static Class<?> loadClass2(String className, Class<?> callingClass)
-
Field Details
-
MANAGER
-
-
Constructor Details
-
ClassLoaderUtils
public ClassLoaderUtils()
-
-
Method Details
-
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
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
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
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
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
-
loadClass
public static Class<?> loadClass(String className, Class<?> callingClass) throws ClassNotFoundException - Throws:
ClassNotFoundException
-
loadClass2
private static Class<?> loadClass2(String className, Class<?> callingClass) throws ClassNotFoundException - Throws:
ClassNotFoundException
-