Package org.apache.commons.discovery.resource.classes

Examples of org.apache.commons.discovery.resource.classes.DiscoverClasses


                           : properties.getProperties(spi, loaders);
       
        String[] classNames = discoverClassNames(spi, props);
       
        if (classNames.length > 0) {
            DiscoverClasses classDiscovery = new DiscoverClasses(loaders);
           
            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);
            }
View Full Code Here


     *         and verify that it implements the SPI.
     *         (this forces the check, no way out..).
     */
    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) {
View Full Code Here

        }
       
       
        GatherResourceClassesListener listener = new GatherResourceClassesListener();

        DiscoverClasses classDiscovery = new DiscoverClasses(loaders);
        classDiscovery.setListener(listener);

        DiscoverServiceNames discoverServices = new DiscoverServiceNames(loaders);
        discoverServices.setListener(classDiscovery);
        discoverServices.find(spi.getSPName());
View Full Code Here

        org.apache.commons.discovery.log.SimpleLog.setLevel(logLevel);

        ClassLoaders loaders = ClassLoaders.getAppLoaders(TestInterface2.class, getClass(), false);
        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 ) {
View Full Code Here

        return nameDiscoverer;
    }

    public static ResourceClassIterator getResourceClassIterator(Class spi) {
        ResourceNameIterator it = getNameDiscoverer().findResourceNames(spi.getName());
        return new DiscoverClasses(loaders).findResourceClasses(it);
    }
View Full Code Here

        return nameDiscoverer;
    }
   
    public static ResourceClassIterator getResourceClassIterator(Class spi) {
        ResourceNameIterator it = getNameDiscoverer().findResourceNames(spi.getName());
        return new DiscoverClasses(loaders).findResourceClasses(it);
    }
View Full Code Here

     * Attempts to resolve the given URI to be associated with a TagLibrary
     * otherwise null is returned to indicate no tag library could be found
     * so that the namespace URI should be treated as just vanilla XML.
     */
    public TagLibrary resolveTagLibrary(String uri) {
        DiscoverClasses discovery = getDiscoverClasses();
        String name = uri;
        if ( uri.startsWith( "jelly:" ) ) {
            name = "jelly." + uri.substring(6);
        }

        log.info( "Looking up service name: " + name );

/*
        ClassLoaders loaders = ClassLoaders.getAppLoaders(TagLibrary.class, getClass(), false);

        DiscoverClass discover = new DiscoverClass(loaders);
        Class implClass = discover.find(TestInterface2.class);



        TagLibrary answer = null;
        try {
            answer = (TagLibrary) DiscoverSingleton.find(TagLibrary.class, name);
        }
        catch (Exception e) {
            log.error( "Could not load service: " + name );
        }
        return answer;
*/
        ResourceClassIterator iter = discovery.findResourceClasses(name);
        while (iter.hasNext()) {
            ResourceClass resource = iter.nextResourceClass();
            try {
                Class typeClass = resource.loadClass();
                if ( typeClass != null ) {
View Full Code Here

     *  This object is lazily created if it has not been configured.
     */
    public DiscoverClasses getDiscoverClasses() {
        if ( discovery == null ) {
            ClassLoaders loaders = ClassLoaders.getAppLoaders(TagLibrary.class, getClass(), false);
            discovery = new DiscoverClasses(loaders);
        }
        return discovery;
    }
View Full Code Here

        return nameDiscoverer;
    }
   
    public static ResourceClassIterator getResourceClassIterator(Class spi) {
        ResourceNameIterator it = getNameDiscoverer().findResourceNames(spi.getName());
        return new DiscoverClasses(loaders).findResourceClasses(it);
    }
View Full Code Here

        return nameDiscoverer;
    }

    public static ResourceClassIterator getResourceClassIterator(Class spi) {
        ResourceNameIterator it = getNameDiscoverer().findResourceNames(spi.getName());
        return new DiscoverClasses(loaders).findResourceClasses(it);
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.discovery.resource.classes.DiscoverClasses

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.