public class ClassLoaderUtil extends Object
It has come out of many months of frustrating use of multiple application servers at Atlassian, please don't change things unless you're sure they're not going to break in one server or another!
It was brought in from oscore trunk revision 147.
| 限定符和类型 | 类和说明 |
|---|---|
protected static class |
ClassLoaderUtil.AggregateIterator<E>
Aggregates Enumeration instances into one iterator and filters out duplicates.
|
| 构造器和说明 |
|---|
ClassLoaderUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static URL |
getResource(String resourceName,
Class callingClass)
Load a given resource.
|
static InputStream |
getResourceAsStream(String resourceName,
Class callingClass)
This is a convenience method to load a resource as a stream.
|
static Iterator<URL> |
getResources(String resourceName,
Class callingClass,
boolean aggregate)
Load all resources with a given name, potentially aggregating all results
from the searched classloaders.
|
static Class |
loadClass(String className,
Class callingClass)
Load a class with a given name.
|
public static Iterator<URL> getResources(String resourceName, Class callingClass, boolean aggregate) throws IOException
This method will try to load the resources using the following methods (in order):
resourceName - The name of the resources to loadcallingClass - The Class object of the calling objectIOExceptionpublic static URL getResource(String resourceName, Class callingClass)
This method will try to load the resource using the following methods (in order):
resourceName - The name IllegalStateException("Unable to call ")of the resource to loadcallingClass - The Class object of the calling objectpublic static InputStream getResourceAsStream(String resourceName, Class callingClass)
The algorithm used to find the resource is given in getResource()
resourceName - The name of the resource to loadcallingClass - The Class object of the calling objectpublic static Class loadClass(String className, Class callingClass) throws ClassNotFoundException
It will try to load the class in the following order:
className - The name of the class to loadcallingClass - The Class object of the calling objectClassNotFoundException - If the class cannot be found anywhere.Copyright © 2023 onecode. All rights reserved.