Bali Share 1.1.18

oracle.bali.share.util
Class ClassLoaderUtils

java.lang.Object
  |
  +--oracle.bali.share.util.ClassLoaderUtils

public class ClassLoaderUtils
extends java.lang.Object

Utility methods for accessing classes and resources using an appropriate class loader.


Method Summary
static java.lang.ClassLoader getContextClassLoader()
          Dynamically accesses the current context class loader.
static java.net.URL getResource(java.lang.String name)
          Locates the resource with the specified name.
static java.net.URL getResource(java.lang.String name, java.lang.ClassLoader callerClassLoader)
          Locates the resource with the specified name.
static java.io.InputStream getResourceAsStream(java.lang.String name)
          Locates the stream resource with the specified name.
static java.io.InputStream getResourceAsStream(java.lang.String name, java.lang.ClassLoader callerClassLoader)
          Locates the resource stream with the specified name.
static java.lang.Class loadClass(java.lang.String name)
          Loads the class with the specified name.
static java.lang.Class loadClass(java.lang.String name, java.lang.ClassLoader callerClassLoader)
          Loads the class with the specified name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

loadClass

public static java.lang.Class loadClass(java.lang.String name)
                                 throws java.lang.ClassNotFoundException
Loads the class with the specified name. For Java 2 callers, the current thread's context class loader is preferred, falling back on the system class loader of the caller when the current thread's context is not set, or the caller is pre Java 2.
Parameters:
name - the name of the class
Returns:
the resulting Class object
Throws:
java.lang.ClassNotFoundException - if the class was not found

getResource

public static java.net.URL getResource(java.lang.String name)
Locates the resource with the specified name. For Java 2 callers, the current thread's context class loader is preferred, falling back on the system class loader of the caller when the current thread's context is not set, or the caller is pre Java 2.
Parameters:
name - the name of the resource
Returns:
the resulting URL object

getResourceAsStream

public static java.io.InputStream getResourceAsStream(java.lang.String name)
Locates the stream resource with the specified name. For Java 2 callers, the current thread's context class loader is preferred, falling back on the system class loader of the caller when the current thread's context is not set, or the caller is pre Java 2.
Parameters:
name - the name of the resource
Returns:
the resulting InputStream object

loadClass

public static java.lang.Class loadClass(java.lang.String name,
                                        java.lang.ClassLoader callerClassLoader)
                                 throws java.lang.ClassNotFoundException
Loads the class with the specified name. For Java 2 callers, the current thread's context class loader is preferred, falling back on the class loader of the caller when the current thread's context is not set, or the caller is pre Java 2. If the callerClassLoader is null, then fall back on the system class loader.
Parameters:
name - the name of the class
callerClassLoader - the calling class loader context
Returns:
the resulting Class object
Throws:
java.lang.ClassNotFoundException - if the class was not found

getResource

public static java.net.URL getResource(java.lang.String name,
                                       java.lang.ClassLoader callerClassLoader)
Locates the resource with the specified name. For Java 2 callers, the current thread's context class loader is preferred, falling back on the class loader of the caller when the current thread's context is not set, or the caller is pre Java 2. If the callerClassLoader is null, then fall back on the system class loader.
Parameters:
name - the name of the resource
callerClassLoader - the calling class loader context
Returns:
the resulting URL object

getResourceAsStream

public static java.io.InputStream getResourceAsStream(java.lang.String name,
                                                      java.lang.ClassLoader callerClassLoader)
Locates the resource stream with the specified name. For Java 2 callers, the current thread's context class loader is preferred, falling back on the class loader of the caller when the current thread's context is not set, or the caller is pre Java 2. If the callerClassLoader is null, then fall back on the system class loader.
Parameters:
name - the name of the resource
callerClassLoader - the calling class loader context
Returns:
the resulting InputStream object

getContextClassLoader

public static java.lang.ClassLoader getContextClassLoader()
Dynamically accesses the current context class loader. Returns null if there is no per-thread context class loader.

Bali Share 1.1.18