Package org.apache.commons.discovery.listeners

Examples of org.apache.commons.discovery.listeners.FirstResourceListener


    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();
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.discovery.listeners.FirstResourceListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.