- java.lang.Object
-
- ch.qos.logback.core.util.Loader
-
-
Field Summary
Fields Modifier and Type Field Description static StringIGNORE_TCL_PROPERTY_NAME
-
Constructor Summary
Constructors Constructor Description Loader()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ClassLoadergetClassLoaderOfClass(Class<?> clazz)Return the class loader which loaded the class passed as argument.static ClassLoadergetClassLoaderOfObject(Object o)Get the class loader of the object passed as argument.static URLgetResource(String resource, ClassLoader classLoader)Search for a resource using the classloader passed as parameter.static URLgetResourceBySelfClassLoader(String resource)Attempt to find a resource by using the classloader that loaded this class, namely Loader.class.static Set<URL>getResources(String resource, ClassLoader classLoader)Compute the number of occurrences a resource can be found by a class loader.static ClassLoadergetTCL()Get the Thread Context Loader which is a JDK 1.2 feature.static booleanisClassLoadable(String className, Context context)Check whether a given class is loadable by the class loader that loaded the context parameter.static Class<?>loadClass(String clazz)If running under JDK 1.2 load the specified class using theThreadcontextClassLoaderif that fails try Class.forname.static Class<?>loadClass(String clazz, Context context)static ClassLoadersystemClassloaderIfNull(ClassLoader cl)This method is used to sanitize theclargument in case it is null.
-
-
-
Field Detail
-
IGNORE_TCL_PROPERTY_NAME
public static final String IGNORE_TCL_PROPERTY_NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Loader
public Loader()
-
-
Method Detail
-
systemClassloaderIfNull
public static ClassLoader systemClassloaderIfNull(ClassLoader cl)
This method is used to sanitize theclargument in case it is null.- Parameters:
cl- a class loader, may be null- Returns:
- the system class loader if the
clargument is null, returnclotherwise. - Since:
- 1.4.12
-
getResources
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.- Parameters:
resource-classLoader-- Returns:
- Throws:
IOException
-
getResource
public static URL getResource(String resource, ClassLoader classLoader)
Search for a resource using the classloader passed as parameter.- Parameters:
resource- the resource name to look forclassLoader- the classloader used for the search
-
getResourceBySelfClassLoader
public static URL getResourceBySelfClassLoader(String resource)
Attempt to find a resource by using the classloader that loaded this class, namely Loader.class.- Parameters:
resource-- Returns:
-
getTCL
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 returnsnull.
-
loadClass
public static Class<?> loadClass(String clazz, Context context) throws ClassNotFoundException
- Throws:
ClassNotFoundException
-
getClassLoaderOfObject
public static ClassLoader getClassLoaderOfObject(Object o)
Get the class loader of the object passed as argument. Return the system class loader if appropriate.- Parameters:
o-- Returns:
-
isClassLoadable
public static boolean isClassLoadable(String className, Context context)
Check whether a given class is loadable by the class loader that loaded the context parameter.- Parameters:
className- the class to check for availabilitycontext- the context object used to find the class loader- Returns:
- true if className is available, false otherwise
- Since:
- 1.5.18
-
getClassLoaderOfClass
public static ClassLoader getClassLoaderOfClass(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.- Parameters:
clazz-- Returns:
-
loadClass
public static Class<?> loadClass(String clazz) throws ClassNotFoundException
If running under JDK 1.2 load the specified class using theThreadcontextClassLoaderif that fails try Class.forname. Under JDK 1.1 only Class.forName is used.- Throws:
ClassNotFoundException
-
-