Package org.apache.commons.discovery.resource

Examples of org.apache.commons.discovery.resource.DiscoverResources


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


                                       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

   
    /**
     *  Construct a new resource discoverer
     */
    public DiscoverNamesInFile() {
        this.discoverResources = new DiscoverResources();
        this.discoverResources.setListener(this);
    }
View Full Code Here

   
    /**
     *  Construct a new resource discoverer
     */
    public DiscoverNamesInFile(ClassLoaders loaders) {
        this.discoverResources = new DiscoverResources(loaders);
        this.discoverResources.setListener(this);
    }
View Full Code Here

    public void execute() throws Exception {
        System.out.println("XXX ");
       
        GatherResourcesListener listener = new GatherResourcesListener();
        DiscoverResources disc = new DiscoverResources();
        disc.addClassLoader( JDKHooks.getJDKHooks().getThreadContextClassLoader() );
        disc.addClassLoader( this.getClass().getClassLoader() );
        disc.setListener(listener);
        disc.find(name);

        Vector vector = listener.getResources();
        drivers = new String[vector.size()];
        for (int i = 0; i < vector.size(); i++) {
            drivers[i] = ((Resource)vector.get(i)).getName();
View Full Code Here

        String name = "testResource";
       
        String partialPaths[] = { "/test/", "/testAlt1/", "/testAlt2/" };
        int expected = partialPaths.length;
       
        DiscoverResources discovery = new DiscoverResources(loaders);
        ResourceIterator iter = discovery.findResources(name);
        int count = 0;
        while (iter.hasNext()) {
            Resource resource = iter.nextResource();
            URL url = resource.getResource();
            if ( url != null ) {
View Full Code Here

    }

    public void execute() throws Exception {
        System.out.println("XXX ");
       
        DiscoverResources disc = new DiscoverResources();
        disc.addClassLoader( JDKHooks.getJDKHooks().getThreadContextClassLoader() );
        disc.addClassLoader( this.getClass().getClassLoader() );
       
        ResourceNameIterator iterator = disc.findResources(name);

        Vector vector = new Vector();
        while (iterator.hasNext()) {
            String resourceInfo = iterator.nextResourceName();
            vector.add(resourceInfo);
View Full Code Here

TOP

Related Classes of org.apache.commons.discovery.resource.DiscoverResources

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.