Package org.apache.commons.discovery

Examples of org.apache.commons.discovery.ResourceClass


            ResourceClassIterator classes =
                classDiscovery.findResourceClasses(classNames[0]);
           
            // If it's set as a property.. it had better be there!
            if (classes.hasNext()) {
                ResourceClass info = classes.nextResourceClass();
                try {
                    return info.loadClass();
                } catch (Exception e) {
                    // ignore
                }
            }
        } else {
            ResourceNameIterator classIter =
                (new DiscoverServiceNames(loaders)).findResourceNames(spi.getSPName());

            ResourceClassIterator classes =
                (new DiscoverClasses(loaders)).findResourceClasses(classIter);
               
           
            if (!classes.hasNext()  &&  defaultImpl != null) {
                return defaultImpl.getDefaultClass(spi, loaders);
            }
           
            // Services we iterate through until we find one that loads..
            while (classes.hasNext()) {
                ResourceClass info = classes.nextResourceClass();
                try {
                    return info.loadClass();
                } catch (Exception e) {
                    // ignore
                }
            }
        }
View Full Code Here


    public Class getDefaultClass(SPInterface spi, ClassLoaders loaders) {
        if (defaultClass == null) {
            DiscoverClasses classDiscovery = new DiscoverClasses(loaders);
            ResourceClassIterator classes = classDiscovery.findResourceClasses(getDefaultName());
            if (classes.hasNext()) {
                ResourceClass info = classes.nextResourceClass();
                try {
                    defaultClass = info.loadClass();
                } catch (Exception e) {
                    // ignore
                }
            }
        }
View Full Code Here

        String name = "org.apache.commons.discovery.test.TestImpl2_1";
       
        DiscoverClasses discovery = new DiscoverClasses(loaders);
        ResourceClassIterator iter = discovery.findResourceClasses(name);
        while (iter.hasNext()) {
            ResourceClass resource = iter.nextResourceClass();
            try {               
                Class implClass = resource.loadClass();
                if ( implClass != null ) {
                    assertEquals("org.apache.commons.discovery.test.TestImpl2_1", implClass.getName());
                    return;
                }
            }
View Full Code Here

                return obj;
            }

            private Object getNextClassInstance() {
                while (services.hasNext()) {
                    ResourceClass info = services.nextResourceClass();
                    try {
                        return spi.newInstance(info.loadClass());
                    } catch (Exception e) {
                        // ignore
                    }
                }
                return null;
View Full Code Here

                }
                return resource != null;
            }
           
            public ResourceClass nextResourceClass() {
                ResourceClass rsrc = resource;
                resource = null;
                return rsrc;
            }
           
            private ResourceClass getNextResource() {
View Full Code Here

                }
                return resource != null;
            }
           
            public ResourceClass nextResourceClass() {
                ResourceClass element = resource;
                resource = null;
                return element;
            }
           
            private ResourceClass getNextClass() {
                while (idx < getClassLoaders().size()) {
                    ClassLoader loader = getClassLoaders().get(idx++);
                    URL url = loader.getResource(resourceName);
                    if (url != null) {
                        if (!history.contains(url)) {
                            history.addElement(url);
   
                            if (log.isDebugEnabled())
                                log.debug("getNextClass: next URL='" + url + "'");
   
                            return new ResourceClass(className, url, loader);
                        }
                        if (log.isDebugEnabled())
                            log.debug("getNextClass: duplicate URL='" + url + "'");
                    } else {
                        if (log.isDebugEnabled())
View Full Code Here

       
        if (classNames.length > 0) {
            classDiscovery.find(classNames[0]);

            // If it's set as a property.. it had better be there!
            ResourceClass resource = listener.getFirst();
            return (resource == null) ? null : resource.loadClass();
        } else {
            DiscoverServiceNames discoverServices = new DiscoverServiceNames(loaders);
   
            /**
             * Feed service (name) discovery to classDiscovery
             */
            discoverServices.setListener(classDiscovery);

            discoverServices.find(spi.getSPName());
            ResourceClass resource = listener.getFirst();

            Class clazz = (resource == null) ? null : resource.loadClass();

            if (clazz != null) {
                return clazz;
            }
           
View Full Code Here

                return obj;
            }

            private Object getNextClassInstance() {
                while (services.hasNext()) {
                    ResourceClass info = services.nextResourceClass();
                    try {
                        return spi.newInstance(info.loadClass());
                    } catch (Exception e) {
                        // ignore
                    }
                }
                return null;
View Full Code Here

                }
                return resource != null;
            }
           
            public ResourceClass nextResourceClass() {
                ResourceClass element = resource;
                resource = null;
                return element;
            }
           
            private ResourceClass getNextClass() {
                while (idx < getClassLoaders().size()) {
                    ClassLoader loader = getClassLoaders().get(idx++);
                    URL url = loader.getResource(resourceName);
                    if (url != null) {
                        if (!history.contains(url)) {
                            history.addElement(url);
   
                            if (log.isDebugEnabled())
                                log.debug("getNextClass: next URL='" + url + "'");
   
                            return new ResourceClass(className, url, loader);
                        }
                        if (log.isDebugEnabled())
                            log.debug("getNextClass: duplicate URL='" + url + "'");
                    } else {
                        if (log.isDebugEnabled())
View Full Code Here

                }
                return resource != null;
            }
           
            public ResourceClass nextResourceClass() {
                ResourceClass rsrc = resource;
                resource = null;
                return rsrc;
            }
           
            private ResourceClass getNextResource() {
View Full Code Here

TOP

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

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.