Class Loader
- java.lang.Object
-
- org.apache.log4j.helpers.Loader
-
public class Loader extends java.lang.ObjectLoad resources (or images) from various sources.
-
-
Constructor Summary
Constructors Constructor Description Loader()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static java.net.URLgetResource(java.lang.String resource)This method will search forresourcein different places.static java.net.URLgetResource(java.lang.String resource, java.lang.Class clazz)Deprecated.as of 1.2.private static java.lang.ClassLoadergetTCL()Get the Thread Context Loader which is a JDK 1.2 feature.private static java.net.URLinnerGetResource(java.lang.String resource, java.lang.ClassLoader classLoader)static booleanisJava1()Deprecated.with no replacementstatic java.lang.ClassloadClass(java.lang.String clazz)Load the specified class using the method.
-
-
-
Field Detail
-
TSTR
static final java.lang.String TSTR
- See Also:
- Constant Field Values
-
ignoreTCL
private static boolean ignoreTCL
-
-
Method Detail
-
getResource
public static java.net.URL getResource(java.lang.String resource, java.lang.Class clazz)Deprecated.as of 1.2.Get a resource by delegating to getResource(String).- Parameters:
resource- resource nameclazz- class, ignored.- Returns:
- URL to resource or null.
-
getResource
public static java.net.URL getResource(java.lang.String resource)
This method will search forresourcein different places. The search order is as follows:Search for
resourceusing the thread context class loader, unless "log4j.ignoreTCL" system property was set to true.Search for
resourceusing the class loader that loaded this class (Loader).- Try one last time with
ClassLoader.getSystemResource(resource), that is using the system class loader.
Nota bene: In versions of reload4j 1.2.23 and earlier, the javadoc documentation stated that the thread context class loader was used but when running under JDK 9 and later this was not actually the case. As of version 1.2.25, the javadoc corresponds to the original intention as documented.
- Parameters:
resource- the resource to load
-
innerGetResource
private static java.net.URL innerGetResource(java.lang.String resource, java.lang.ClassLoader classLoader)
-
isJava1
@Deprecated public static boolean isJava1()
Deprecated.with no replacementAre we running under JDK 1.x?
-
getTCL
private static java.lang.ClassLoader getTCL() throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetExceptionGet 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.- Throws:
java.lang.IllegalAccessExceptionjava.lang.reflect.InvocationTargetException
-
loadClass
public static java.lang.Class loadClass(java.lang.String clazz) throws java.lang.ClassNotFoundExceptionLoad the specified class using the method.Nota bene: In versions of reload4j 1.2.23 and earlier, the documentation stated that the thread context class loader was used to load the specified class. However, when running under JDK 9 and later this was not actually the case. Version 1.2.5 fixes this discrepancy.
- Parameters:
clazz- the name of class to load- Throws:
java.lang.ClassNotFoundException
-
-