private Class getClassFromBundles()

in src/main/java/org/apache/sling/commons/classloader/impl/PackageAdminClassLoader.java [274:302]


    private Class<?> getClassFromBundles(String name) throws ClassNotFoundException {
        Class<?> clazz = null;
        String packageName = getPackageFromClassName(name);
        Bundle providingBundle = packageProviders.get(packageName);
        if (providingBundle == null) {
            Set<Bundle> bundles = findBundlesForPackage(packageName);
            for (Bundle bundle : bundles) {
                try {
                    clazz = bundle.loadClass(name);
                    this.factory.addUsedBundle(bundle);
                    packageProviders.put(packageName, bundle);
                    LOGGER.debug("Marking bundle {}:{} as the provider for API package {}.", bundle.getSymbolicName(), bundle
                            .getVersion().toString(), packageName);
                    break;
                } catch (ClassNotFoundException innerCNFE) {
                    // do nothing; we need to loop over the bundles providing the class' package
                }
            }
        } else {
            try {
                clazz = providingBundle.loadClass(name);
                this.factory.addUsedBundle(providingBundle);
            } catch (ClassNotFoundException icnfe) {
                throw new ClassNotFoundException(String.format("Cannot find class %s in bundle %s:%s which was marked as the provider for" +
                        " package %s.", name, providingBundle.getSymbolicName(), providingBundle.getVersion().toString(), packageName), icnfe);
            }
        }
        return clazz;
    }