|
Jive Forums API (5.5.8) Developer Javadocs | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.jivesoftware.util.ClassUtils
public class ClassUtils
A utility class to assist with loading classes or resources by name. Many application servers use custom classloaders, which will break uses of:
Class.forName(className);
This utility attempts to load the class or resource using a number of different
mechanisms to work around this problem.
| Method Summary | |
|---|---|
static java.lang.Class |
forName(java.lang.String className)
Loads the class with the specified name. |
static java.net.URL |
getResource(java.lang.String resourceName,
java.lang.Class callingClass)
Load a given resource. |
static java.io.InputStream |
getResourceAsStream(java.lang.String name)
Loads the given resource as a stream. |
static java.io.InputStream |
getResourceAsStream(java.lang.String resourceName,
java.lang.Class callingClass)
This is a convenience method to load a resource as a stream. |
static java.lang.Class |
loadClass(java.lang.String className,
java.lang.Class callingClass)
Load a class with a given name. |
static java.lang.Object |
newInstance(java.lang.String className)
Creates a new instance of the class with the specified name. |
static void |
propertiesLoaded()
|
static byte[] |
readStream(java.io.InputStream in,
int size)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static java.lang.Class forName(java.lang.String className)
throws java.lang.ClassNotFoundException
className - the name of the class
Class object
java.lang.ClassNotFoundException - if the class was not found
public static java.lang.Object newInstance(java.lang.String className)
throws java.lang.ClassNotFoundException,
java.lang.IllegalAccessException,
java.lang.InstantiationException
className - The name of the class
java.lang.ClassNotFoundException - If class cannot be found.
java.lang.IllegalAccessException - If caller cannot access the class.
java.lang.InstantiationException - If class instantiation fails.public static java.io.InputStream getResourceAsStream(java.lang.String name)
name - the name of the resource that exists in the classpath.
public static void propertiesLoaded()
public static java.lang.Class loadClass(java.lang.String className,
java.lang.Class callingClass)
throws java.lang.ClassNotFoundException
Thread.currentThread().getContextClassLoader()
Class.forName(String)
ClassLoaderUtil.class.getClassLoader()
callingClass.getClassLoader()
className - The name of the class to loadcallingClass - The Class object of the calling object
java.lang.ClassNotFoundException - If the class cannot be found anywhere.
public static java.net.URL getResource(java.lang.String resourceName,
java.lang.Class callingClass)
Thread.currentThread().getContextClassLoader()
ClassLoaderUtil.class.getClassLoader()
callingClass.getClassLoader()
resourceName - The name of the resource to loadcallingClass - The Class object of the calling object
public static java.io.InputStream getResourceAsStream(java.lang.String resourceName,
java.lang.Class callingClass)
resourceName - The name of the resource to loadcallingClass - The Class object of the calling object
public static byte[] readStream(java.io.InputStream in,
int size)
throws java.io.IOException
java.io.IOException
|
Jive Forums Project Page | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||