public class ClassLoaderHelper extends Object
PrivilegedAction
with privileges enabled. The action is performed with all of
the permissions possessed by the caller's protection domain.Constructor and Description |
---|
ClassLoaderHelper() |
Modifier and Type | Method and Description |
---|---|
static String |
getClassLoaderLogName(ClassLoader cl) |
static ClassLoader |
getContextClassLoader() |
static Class |
loadClass(String className) |
static Class |
loadClass(String className,
boolean localOnly)
Load the desired class by the context ClassLoader for current Thread.
|
static Class |
loadClass(String className,
boolean localOnly,
Class defaultClass) |
static Class |
loadClass(String codebase,
String className,
ClassLoader classLoader) |
static Class |
loadClass(String codebase,
String className,
ClassLoader classLoader,
boolean localOnly)
Load the desired class by the context ClassLoader for current Thread, or by use of
RMIClassLoader which loads a class from a codebase URL path, optionally using the supplied
loader.
|
static Class |
loadLocalClass(String className) |
static <T> T |
newInstance(String className) |
static void |
setContextClassLoader(ClassLoader cl,
boolean ignoreSecurity)
Set current thread context ClassLoader.
|
public static <T> T newInstance(String className) throws ClassNotFoundException, IllegalAccessException, InstantiationException
public static Class loadClass(String className) throws ClassNotFoundException
ClassNotFoundException
public static Class loadLocalClass(String className) throws ClassNotFoundException
ClassNotFoundException
public static Class loadClass(String className, boolean localOnly) throws ClassNotFoundException
className
- the desired class to load.localOnly
- whether or not to use the remote LRMI class loader.ClassNotFoundException
- Failed to load the desired class.public static Class loadClass(String codebase, String className, ClassLoader classLoader) throws ClassNotFoundException, MalformedURLException
public static Class loadClass(String codebase, String className, ClassLoader classLoader, boolean localOnly) throws ClassNotFoundException, MalformedURLException
loadClass(String)
methods with the className as argument, and if fails, delegates
to the RMIClassLoaderSpi.loadClass(String,String,ClassLoader) method of the provider
instance, passing codebase as the first argument, className as the second
argument, and defaultLoader as the third argument.codebase
- the list of URLs (separated by spaces) to load the class from, or null
name the name of the class to loadclassName
- the name of the class to loadclassLoader
- additional contextual class loader to use, or nulllocalOnly
- whether or not to use the remote class loader.ClassNotFoundException
- if a definition for the class could not be found at the
specified locationMalformedURLException
- if codebase is non-null and contains an invalid URL, or if
codebase is null and a provider-specific URL used to load
classes is invalidpublic static ClassLoader getContextClassLoader()
public static void setContextClassLoader(ClassLoader cl, boolean ignoreSecurity)
cl
- the classLoader to set.ignoreSecurity
- if true
the java security will be ignored(to gain
performance), the direct reflection-field call will attempt to set
contextClassLoader without calling thread method Thread.setContextClassLoader(ClassLoader)
. If non secured call was
failed, the context will be set by regular way via Thread.setContextClassLoader(ClassLoader)
.public static String getClassLoaderLogName(ClassLoader cl)
Copyright © GigaSpaces.