Top Description Fields Constructors Methods
ch.qos.logback.core.util

public Class Loader

extends Object
Class Inheritance
Imports
java.io.IOException, java.net.URL, java.security.AccessController, .PrivilegedAction, java.util.Enumeration, .Set, .HashSet, ch.qos.logback.core.Context

Load resources (or images) from various sources.
Author
Ceki Gülcü

Field Summary

Modifier and TypeField and Description
private static boolean
public static final String
private static boolean
pack-priv static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static ClassLoader
getClassLoaderAsPrivileged(final Class<?> clazz)

Returns the class loader of clazz in an access privileged section.

public static ClassLoader
getClassLoaderOfClass(final Class<?> clazz)

Return the class loader which loaded the class passed as argument.

public static ClassLoader
getClassLoaderOfObject(Object o)

Get the class loader of the object passed as argument.

public static URL
getResource(String
the resource name to look for
resource
,
ClassLoader
the classloader used for the search
classLoader
)

Search for a resource using the classloader passed as parameter.

public static URL
getResourceBySelfClassLoader(String resource)

Attempt to find a resource by using the classloader that loaded this class, namely Loader.class.

public static Set<URL>
getResources(String resource, ClassLoader classLoader)

Compute the number of occurrences a resource can be found by a class loader.

public static ClassLoader
getTCL()

Get the Thread Context Loader which is a JDK 1.2 feature.

public static Class<?>
loadClass(String clazz, Context context)

public static Class<?>
loadClass(String clazz)

If running under JDK 1.2 load the specified class using the Thread contextClassLoader if that fails try Class.forname.

public static ClassLoader

Returns:

the system class loader if the cl argument is null, return cl otherwise.
systemClassloaderIfNull
(ClassLoader
a class loader, may be null
cl
)

This method is used to sanitize the cl argument in case it is null.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

HAS_GET_CLASS_LOADER_PERMISSIONback to summary
private static boolean HAS_GET_CLASS_LOADER_PERMISSION
IGNORE_TCL_PROPERTY_NAMEback to summary
public static final String IGNORE_TCL_PROPERTY_NAME
ignoreTCLback to summary
private static boolean ignoreTCL
TSTRback to summary
pack-priv static final String TSTR

Constructor Detail

Loaderback to summary
public Loader()

Method Detail

getClassLoaderAsPrivilegedback to summary
public static ClassLoader getClassLoaderAsPrivileged(final Class<?> clazz)

Returns the class loader of clazz in an access privileged section.

getClassLoaderOfClassback to summary
public static ClassLoader getClassLoaderOfClass(final Class<?> clazz)

Return the class loader which loaded the class passed as argument. Return the system class loader if the class loader of 'clazz' argument is null.

getClassLoaderOfObjectback to summary
public static ClassLoader getClassLoaderOfObject(Object o)

Get the class loader of the object passed as argument. Return the system class loader if appropriate.

getResourceback to summary
public static URL getResource(String resource, ClassLoader classLoader)

Search for a resource using the classloader passed as parameter.

Parameters
resource:String

the resource name to look for

classLoader:ClassLoader

the classloader used for the search

getResourceBySelfClassLoaderback to summary
public static URL getResourceBySelfClassLoader(String resource)

Attempt to find a resource by using the classloader that loaded this class, namely Loader.class.

getResourcesback to summary
public static Set<URL> getResources(String resource, ClassLoader classLoader) throws IOException

Compute the number of occurrences a resource can be found by a class loader.

getTCLback to summary
public static ClassLoader getTCL()

Get the Thread Context Loader which is a JDK 1.2 feature. If we are running under JDK 1.1 or anything else goes wrong the method returns null.

loadClassback to summary
public static Class<?> loadClass(String clazz, Context context) throws ClassNotFoundException
loadClassback to summary
public static Class<?> loadClass(String clazz) throws ClassNotFoundException

If running under JDK 1.2 load the specified class using the Thread contextClassLoader if that fails try Class.forname. Under JDK 1.1 only Class.forName is used.

systemClassloaderIfNullback to summary
public static ClassLoader systemClassloaderIfNull(ClassLoader cl)

This method is used to sanitize the cl argument in case it is null.

Parameters
cl:ClassLoader

a class loader, may be null

Returns:ClassLoader

the system class loader if the cl argument is null, return cl otherwise.

Since
1.4.12