Package org.apache.commons.discovery

Examples of org.apache.commons.discovery.ResourceIterator


     * Locate resources that are bound to <code>resourceNames</code>.
     *
     * @return ResourceIterator
     */
    public ResourceIterator findResources(final ResourceNameIterator inputNames) {
        return new ResourceIterator() {
            private ResourceIterator resources = null;
            private Resource resource = null;
           
            public boolean hasNext() {
                if (resource == null) {
View Full Code Here


                log.debug("find: serviceName = '" + fileName + "'");
            }
        }


        final ResourceIterator files =
            getDiscover().findResources(fileName);

        return new ResourceNameIterator() {
            private int idx = 0;
            private Vector classNames = null;
            private String resource = null;
           
            public boolean hasNext() {
                if (resource == null) {
                    resource = getNextClassName();
                }
                return resource != null;
            }
           
            public String nextResourceName() {
                String element = resource;
                resource = null;
                return element;
            }
           
            private String getNextClassName() {
                if (classNames == null || idx >= classNames.size()) {
                    classNames = getNextClassNames();
                    idx = 0;
                    if (classNames == null) {
                        return null;
                    }
                }

                String className = (String)classNames.get(idx++);

                if (log.isDebugEnabled())
                    log.debug("getNextClassResource: next class='" + className + "'");

                return className;
            }

            private Vector getNextClassNames() {
                while (files.hasNext()) {
                    Vector results = readServices(files.nextResource());
                    if (results != null  &&  results.size() > 0) {
                        return results;
                    }
                }
                return null;
View Full Code Here

        String partialPaths[] = { "/test-classes/", "/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) {
                if (url.getFile().indexOf(partialPaths[count]) == -1) {
                    fail(url + " does not contain " + partialPaths[count]);
                }
View Full Code Here

     * Locate resources that are bound to <code>resourceNames</code>.
     *
     * @return ResourceIterator
     */
    public ResourceIterator findResources(final ResourceNameIterator inputNames) {
        return new ResourceIterator() {
            private ResourceIterator resources = null;
            private Resource resource = null;
           
            public boolean hasNext() {
                if (resource == null) {
View Full Code Here

                                       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

       
        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 ) {
                System.out.println("URL = " + url.toString());
               
                if (url.getFile().indexOf(partialPaths[count]) == -1) {
View Full Code Here

TOP

Related Classes of org.apache.commons.discovery.ResourceIterator

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.