Package org.jivesoftware.util
Class ClassUtils
java.lang.Object
org.jivesoftware.util.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.- Author:
- Matt Tucker
-
Method Summary
Modifier and TypeMethodDescriptionstatic ClassLoads the class with the specified name.static InputStreamgetResourceAsStream(String name) Loads the given resource as a stream.
-
Method Details
-
forName
Loads the class with the specified name.- Parameters:
className- the name of the class- Returns:
- the resulting
Classobject - Throws:
ClassNotFoundException- if the class was not found
-
getResourceAsStream
Loads the given resource as a stream.- Parameters:
name- the name of the resource that exists in the classpath.- Returns:
- the resource as an input stream or
nullif the resource was not found.
-
loadClass
- Throws:
ClassNotFoundException
-