Package org.apache.commons.discovery

Examples of org.apache.commons.discovery.ResourceClassIterator


         * Find and examine each service
         */
        return (EngineConfigurationFactory)AccessController.doPrivileged(
                new PrivilegedAction() {
                    public Object run() {
                        ResourceClassIterator services = AxisProperties.getResourceClassIterator(mySpi);

                        EngineConfigurationFactory factory = null;

                        while (factory == null  &&  services.hasNext()) {
                            Class service = services.nextResourceClass().loadClass();
               
                            /* service == null
                             * if class resource wasn't loadable
                             */
                            if (service != null) {
View Full Code Here


                        nameDiscoverers.addResourceNameDiscover(new DiscoverNamesInManagedProperties());
                        nameDiscoverers.addResourceNameDiscover(new DiscoverServiceNames(loaders));
                           
                        ResourceNameIterator it = nameDiscoverers.findResourceNames(mySpi.getName());
               
                        ResourceClassIterator services =
                            new DiscoverClasses(loaders).findResourceClasses(it);
               
                        EngineConfigurationFactory factory = null;

                        while (factory == null  &&  services.hasNext()) {
                            Class service = services.nextResourceClass().loadClass();
               
                            factory = newFactory(service, newFactoryParamTypes, params);
                        }
               
                        if (factory == null) {
View Full Code Here

                                })
                            );
                           
                        ResourceNameIterator it = nameDiscoverers.findResourceNames(mySpi.getName());
               
                        ResourceClassIterator services =
                            new DiscoverClasses(loaders).findResourceClasses(it);
               
                        EngineConfigurationFactory factory = null;

                        while (factory == null  &&  services.hasNext()) {
                            Class service = services.nextResourceClass().loadClass();
               
                            /* service == null
                             * if class resource wasn't loadable
                             */
                            if (service != null) {
View Full Code Here

            ClassLoaders.getAppLoaders(mySpi, myFactory, true);

        ResourceNameIterator it =
            new DiscoverServiceNames(loaders).findResourceNames(mySpi.getName());

        ResourceClassIterator services =
            new DiscoverClasses(loaders).findResourceClasses(it);

        EngineConfigurationFactory factory = null;
        while (factory == null  &&  services.hasNext()) {
            Class service = services.nextResourceClass().loadClass();

            factory = newFactory(service, newFactoryParamTypes, params);
        }

        if (factory == null) {
View Full Code Here

        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);
            }
           
            // 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

     *         (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) {
                    // ignore
                }
View Full Code Here

        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 ) {
                    assertEquals("org.apache.commons.discovery.test.TestImpl2_1", implClass.getName());
                    return;
View Full Code Here

        }
       
        ResourceNameIterator servicesIter =
            (new DiscoverServiceNames(loaders)).findResourceNames(spi.getSPName());

        final ResourceClassIterator services =
            (new DiscoverClasses(loaders)).findResourceClasses(servicesIter);
       
        return new Enumeration() {
            private Object object = null;
           
            public boolean hasMoreElements() {
                if (object == null) {
                    object = getNextClassInstance();
                }
                return object != null;
            }
           
            public Object nextElement() {
                Object obj = object;
                object = null;
                return obj;
            }

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

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

        final String resourceName = className.replace('.','/') + ".class";
       
        if (log.isDebugEnabled())
            log.debug("find: className='" + className + "'");

        return new ResourceClassIterator() {
            private Vector history = new Vector();
            private int idx = 0;
            private ResourceClass resource = null;
           
            public boolean hasNext() {
View Full Code Here

TOP

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

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.