Package org.apache.commons.jelly.util
Class ClassLoaderUtils
java.lang.Object
org.apache.commons.jelly.util.ClassLoaderUtils
A class to centralize the class loader management code.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ClassLoadergetClassLoader(Class clazz) Get the loader for the given class.static ClassLoadergetClassLoader(ClassLoader specifiedLoader, boolean useContextClassLoader, Class callingClass) Return the class loader to be used for instantiating application objects when required.static ClassLoadergetClassLoader(ClassLoader specifiedLoader, Class callingClass) Return the class loader to be used for instantiating application objects when a context class loader is not specified.static ClassLoads the given class using the current Thread's context class loader first otherwise use the class loader which loaded this class.static ClassloadClass(String className, ClassLoader specifiedLoader, boolean useContextLoader, Class callingClass) Loads the given class using: the specified classloader, the current Thread's context class loader first, if asked otherwise use the class loader which loaded this class.
-
Constructor Details
-
ClassLoaderUtils
public ClassLoaderUtils()
-
-
Method Details
-
getClassLoader
public static ClassLoader getClassLoader(ClassLoader specifiedLoader, boolean useContextClassLoader, Class callingClass) Return the class loader to be used for instantiating application objects when required. This is determined based upon the following rules:- The specified class loader, if any
- The thread context class loader, if it exists and
useContextClassLoaderis true - The class loader used to load the calling class.
- The System class loader.
-
getClassLoader
Return the class loader to be used for instantiating application objects when a context class loader is not specified. This is determined based upon the following rules:- The specified class loader, if any
- The class loader used to load the calling class.
- The System class loader.
-
getClassLoader
Get the loader for the given class.- Parameters:
clazz- the class to retrieve the loader for- Returns:
- the class loader that loaded the provided class
-
loadClass
Loads the given class using the current Thread's context class loader first otherwise use the class loader which loaded this class.- Throws:
ClassNotFoundException
-
loadClass
public static Class loadClass(String className, ClassLoader specifiedLoader, boolean useContextLoader, Class callingClass) throws ClassNotFoundException Loads the given class using:- the specified classloader,
- the current Thread's context class loader first, if asked
- otherwise use the class loader which loaded this class.
- Throws:
ClassNotFoundException
-