|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.commons.discovery.tools.ResourceUtils
public class ResourceUtils
Mechanisms to locate and load a class. The load methods locate a class only. The find methods locate a class and verify that the class implements an given interface or extends a given class.
| Constructor Summary | |
|---|---|
ResourceUtils()
|
|
| Method Summary | |
|---|---|
static String |
getPackageName(Class<?> clazz)
Get package name. |
static Resource |
getResource(Class<?> spi,
String resourceName,
ClassLoaders loaders)
Load the resource resourceName. |
static Properties |
loadProperties(Class<?> spi,
String propertiesFileName,
ClassLoaders classLoaders)
Load named property file, optionally qualified by spi's package name as per Class.getResource. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ResourceUtils()
| Method Detail |
|---|
public static String getPackageName(Class<?> clazz)
clazz - The class from which the package has to be extracted
public static Resource getResource(Class<?> spi,
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 holder
Resource instance
DiscoveryException - 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 SPI
public static Properties loadProperties(Class<?> spi,
String propertiesFileName,
ClassLoaders classLoaders)
throws DiscoveryException
spi - The SPI typepropertiesFileName - The property file name.classLoaders - The class loaders holder
Properties format
DiscoveryException - 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.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||