* (or extend) the SPI
*/
public static Resource getResource(Class<?> spi,
String resourceName,
ClassLoaders loaders) throws DiscoveryException {
DiscoverResources explorer = new DiscoverResources(loaders);
ResourceIterator resources = explorer.findResources(resourceName);
if (spi != null &&
!resources.hasNext() &&
resourceName.charAt(0) != '/') {
/**
* If we didn't find the resource, and if the resourceName
* isn't an 'absolute' path name, then qualify with
* package name of the spi.
*/
resourceName = getPackageName(spi).replace('.','/') + "/" + resourceName;
resources = explorer.findResources(resourceName);
}
return resources.hasNext()
? resources.nextResource()
: null;