public static Resource getResource(Class spi,
String resourceName,
ClassLoaders loaders)
throws DiscoveryException
{
FirstResourceListener listener = new FirstResourceListener();
DiscoverResources explorer = new DiscoverResources(loaders);
explorer.setListener(listener);
explorer.find(resourceName);
if (spi != null &&
(listener.getFirst() == null) &&
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.
*/
explorer.find(getPackageName(spi).replace('.','/') + "/" + resourceName);
}
return listener.getFirst();
}