org.apache.logging.log4j.core.helpers
Class Loader

java.lang.Object
  extended by org.apache.logging.log4j.core.helpers.Loader

public final class Loader
extends Object

Load resources (or images) from various sources.


Method Summary
static ClassLoader getClassLoader()
          Return the ClassLoader to use.
static URL getResource(String resource, ClassLoader defaultLoader)
          This method will search for resource in different places.
static InputStream getResourceAsStream(String resource, ClassLoader defaultLoader)
          This method will search for resource in different places.
static Class loadClass(String clazz)
          Load a Class by name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getResource

public static URL getResource(String resource,
                              ClassLoader defaultLoader)
This method will search for resource in different places. The search order is as follows:

  1. Search for resource using the thread context class loader under Java2. If that fails, search for resource using the class loader that loaded this class (Loader). Under JDK 1.1, only the the class loader that loaded this class (Loader) is used.

  2. Try one last time with ClassLoader.getSystemResource(resource), that is is using the system class loader in JDK 1.2 and virtual machine's built-in class loader in JDK 1.1.

Parameters:
resource - The resource to load.
defaultLoader - The default ClassLoader.
Returns:
A URL to the resource.

getResourceAsStream

public static InputStream getResourceAsStream(String resource,
                                              ClassLoader defaultLoader)
This method will search for resource in different places. The search order is as follows:

  1. Search for resource using the thread context class loader under Java2. If that fails, search for resource using the class loader that loaded this class (Loader). Under JDK 1.1, only the the class loader that loaded this class (Loader) is used.

  2. Try one last time with ClassLoader.getSystemResource(resource), that is is using the system class loader in JDK 1.2 and virtual machine's built-in class loader in JDK 1.1.

Parameters:
resource - The resource to load.
defaultLoader - The default ClassLoader.
Returns:
An InputStream to read the resouce.

loadClass

public static Class loadClass(String clazz)
                       throws ClassNotFoundException
Load a Class by name.

Parameters:
clazz - The class name.
Returns:
The Class.
Throws:
ClassNotFoundException - if the Class could not be found.

getClassLoader

public static ClassLoader getClassLoader()
Return the ClassLoader to use.

Returns:
the ClassLoader.


Copyright © 1999-2012 Apache Software Foundation. All Rights Reserved.