private PackageSource findRequiredSource(String pkgName, KeyedHashSet visited) { if (requiredBundles == null) return null; synchronized (requiredSources) { PackageSource result = (PackageSource) requiredSources.getByKey(pkgName); if (result != null) return result.isNullSource() ? null : result; } if (visited == null) visited = new KeyedHashSet(false); visited.add(bundle); // always add ourselves so we do not recurse back to ourselves ArrayList result = new ArrayList(3); for (int i = 0; i < requiredBundles.length; i++) { BundleLoader requiredLoader = requiredBundles[i].getBundleLoader(); requiredLoader.addExportedProvidersFor(proxy.getSymbolicName(), pkgName, result, visited); } // found some so cache the result for next time and return PackageSource source; if (result.size() == 0) { // did not find it in our required bundles lets record the failure // so we do not have to do the search again for this package. source = NullPackageSource.getNullPackageSource(pkgName); } else if (result.size() == 1) { // if there is just one source, remember just the single source source = (PackageSource) result.get(0); } else { // if there was more than one source, build a multisource and cache that. PackageSource[] srcs = (PackageSource[]) result.toArray(new PackageSource[result.size()]); source = createMultiSource(pkgName, srcs); } synchronized (requiredSources) { requiredSources.add(source); } return source.isNullSource() ? null : source; }
public static void closeBundleLoader(BundleLoaderProxy proxy) { if (proxy == null) return; // First close the BundleLoader BundleLoader loader = proxy.getBasicBundleLoader(); if (loader != null) loader.close(); proxy.setStale(); // if proxy is not null then make sure to unset user object // associated with the proxy in the state BundleDescription description = proxy.getBundleDescription(); description.setUserObject(null); }