public class ClassUtils extends Object
Classes, such as acquiring them from the application
ClassLoaders and instantiating Objects from them.
| Constructor and Description |
|---|
ClassUtils()
|
| Modifier and Type | Method and Description |
|---|---|
static Class |
forName(String
Attempts to load the specified class name from the current thread's
context class loader, then the current ClassLoader (
ClassUtils.class.getClassLoader()), then the system/application ClassLoader (
ClassLoader.getSystemClassLoader(), in that order.
|
static Constructor |
getConstructor(Class
|
static InputStream |
getResourceAsStream(String
Returns the specified resource by checking the current thread's
context class loader, then the current ClassLoader (
ClassUtils.class.getClassLoader()), then the system/application ClassLoader (
ClassLoader.getSystemClassLoader(), in that order, using
getResourceAsStream(name).
|
static Object |
instantiate(Constructor
|
static boolean |
isAvailable(String
|
static Object |
newInstance(Class
|
static Object |
newInstance(Class
|
static Object |
newInstance(String
|
static Object |
newInstance(String
|
public static InputStreamgetResourceAsStream(String name)
context class loader, then the current ClassLoader (
ClassUtils.class.getClassLoader()), then the system/application ClassLoader (
ClassLoader.getSystemClassLoader(), in that order, using
getResourceAsStream(name).
name - the name of the resource to acquire from the classloader(s).
null if the resource cannot be found from any of the three mentioned ClassLoaders.
public static ClassforName(String fqcn) throws UnknownClassException
context class loader, then the current ClassLoader (
ClassUtils.class.getClassLoader()), then the system/application ClassLoader (
ClassLoader.getSystemClassLoader(), in that order. If any of them cannot locate the specified class, an
UnknownClassException is thrown (our RuntimeException equivalent of the JRE's
ClassNotFoundException.
fqcn - the fully qualified class name to load
UnknownClassException - if the class cannot be found.
public static boolean isAvailable(StringfullyQualifiedClassName)
public static ConstructorgetConstructor(Class clazz, Class ... argTypes)
public static Objectinstantiate(Constructor ctor, Object ... args)