org.apache.axis.utils
Class ClassUtils
java.lang.Object
org.apache.axis.utils.ClassUtils
public final class ClassUtils
extends java.lang.Object
Utility methods for Class Loading.
- Davanum Srinvas (dims@yahoo.com)
- Matthew Pocock (matthew_pocock@yahoo.co.uk)
static ClassLoader | createClassLoader(String classpath, ClassLoader parent) - Creates a new ClassLoader from a classpath specification and a parent
class loader.
|
static Class | forName(String className) - Use this method instead of Class.forName
|
static Class | forName(String _className, boolean init, ClassLoader _loader) - Use this method instead of Class.forName (String className, boolean init, ClassLoader loader)
|
static ClassLoader | getClassLoader(String className) - Obtain the ClassLoader (if any) associated with the given
className.
|
static ClassLoader | getDefaultClassLoader()
|
static InputStream | getResourceAsStream(Class clazz, String resource) - Get an input stream from a named resource.
|
static InputStream | getResourceAsStream(Class clazz, String resource, boolean checkThreadContextFirst) - Get an input stream from a named resource.
|
static void | removeClassLoader(String className) - Deregister the ClassLoader for a given className.
|
static void | setClassLoader(String className, ClassLoader loader) - Set the ClassLoader associated with the given className.
|
static void | setDefaultClassLoader(ClassLoader loader) - Set the default ClassLoader.
|
createClassLoader
public static ClassLoader createClassLoader(String classpath,
ClassLoader parent)
throws SecurityException
Creates a new ClassLoader from a classpath specification and a parent
class loader.
The classpath string will be split using the system path seperator
character (e.g. : or ;), just as the java system-wide class path is
processed.
classpath
- the classpath Stringparent
- the parent ClassLoader, or null if the default is to be
used
forName
public static Class forName(String className)
throws ClassNotFoundException
Use this method instead of Class.forName
className
- Class name
- java class
forName
public static Class forName(String _className,
boolean init,
ClassLoader _loader)
throws ClassNotFoundException
Use this method instead of Class.forName (String className, boolean init, ClassLoader loader)
_className
- Class nameinit
- initialize the class_loader
- class loader
- java class
getClassLoader
public static ClassLoader getClassLoader(String className)
Obtain the ClassLoader (if any) associated with the given
className.
className
- the name of a class
- class loader
getDefaultClassLoader
public static ClassLoader getDefaultClassLoader()
getResourceAsStream
public static InputStream getResourceAsStream(Class clazz,
String resource)
Get an input stream from a named resource.
Tries
- the classloader that loaded "clazz" first,
- the system classloader
- the class "clazz" itself
clazz
- class to use in the lookupsresource
- resource string to look for
- input stream if found, or null
getResourceAsStream
public static InputStream getResourceAsStream(Class clazz,
String resource,
boolean checkThreadContextFirst)
Get an input stream from a named resource.
Tries
- the classloader that loaded "clazz" first,
- the system classloader
- the class "clazz" itself
clazz
- class to use in the lookupsresource
- resource string to look forcheckThreadContextFirst
- check the thread context first?
- input stream if found, or null
removeClassLoader
public static void removeClassLoader(String className)
Deregister the ClassLoader for a given className.
className
- the name of a class
setClassLoader
public static void setClassLoader(String className,
ClassLoader loader)
Set the ClassLoader associated with the given className. If either the
class name or the loader are null, no action is performed.
className
- the name of a classloader
- the ClassLoader for the class
setDefaultClassLoader
public static void setDefaultClassLoader(ClassLoader loader)
Set the default ClassLoader. If loader is null, the default loader is
not changed.
loader
- the new default ClassLoader
Copyright B) 2005 Apache Web Services Project. All Rights Reserved.