public class ResourceUtils
extends java.lang.Object
| Constructor and Description |
|---|
ResourceUtils() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
getPackageName(java.lang.Class<?> clazz)
Get package name.
|
static Resource |
getResource(java.lang.Class<?> spi,
java.lang.String resourceName,
ClassLoaders loaders)
Load the resource
resourceName. |
static java.util.Properties |
loadProperties(java.lang.Class<?> spi,
java.lang.String propertiesFileName,
ClassLoaders classLoaders)
Load named property file, optionally qualified by spi's package name
as per Class.getResource.
|
public static java.lang.String getPackageName(java.lang.Class<?> clazz)
clazz - The class from which the package has to be extractedpublic static Resource getResource(java.lang.Class<?> spi, java.lang.String resourceName, ClassLoaders loaders) throws DiscoveryException
resourceName.
Try each classloader in succession,
until first succeeds, or all fail.
If all fail and resouceName is not absolute
(doesn't start with '/' character), then retry with
packageName/resourceName after changing all
'.' to '/'.spi - The SPI typeresourceName - The name of the resource to load.loaders - the class loaders holderResource instanceDiscoveryException - if the class implementing
the SPI cannot be found, cannot be loaded and
instantiated, or if the resulting class does not implement
(or extend) the SPIpublic static java.util.Properties loadProperties(java.lang.Class<?> spi,
java.lang.String propertiesFileName,
ClassLoaders classLoaders)
throws DiscoveryException
spi - The SPI typepropertiesFileName - The property file name.classLoaders - The class loaders holderProperties formatDiscoveryException - Thrown if the name of a class implementing
the SPI cannot be found, if the class cannot be loaded and
instantiated, or if the resulting class does not implement
(or extend) the SPI.Copyright (c) 2002 - Apache Software Foundation