public void checkWiringState_6() { ExportPackageDescription[] exports = bundle_6.getResolvedImports(); assertNotNull("export array is unexpectedly null", exports); assertTrue("export array is unexpectedly empty", exports.length > 0); for (int i = 0; i < exports.length; i++) { ExportPackageDescription exp = exports[i]; String exportPackageName = exp.getName(); assertNotNull("package name is null", exportPackageName); if (exportPackageName.equals("org.w3c.dom")) { assertNotNull("Package [org.w3c.dom] is not wired when it should be ", exp.getExporter()); assertEquals("Package [org.w3c.dom] is wired incorrectly ", exp.getExporter(), bundle_4); } else if (exportPackageName.equals("org.xml.sax")) { assertNotNull("Package [org.xml.sax] is not wired when it should be ", exp.getExporter()); assertEquals("Package [org.xml.sax] is wired incorrectly ", exp.getExporter(), bundle_3); } } // end for } // end method
final PackageSource createExportPackageSource( ExportPackageDescription export, KeyedHashSet visited) { BundleLoaderProxy exportProxy = getLoaderProxy(export.getExporter()); if (exportProxy == null) // TODO log error!! return null; PackageSource requiredSource = exportProxy.getBundleLoader().findRequiredSource(export.getName(), visited); PackageSource exportSource = exportProxy.createPackageSource(export, false); if (requiredSource == null) return exportSource; return createMultiSource(export.getName(), new PackageSource[] {requiredSource, exportSource}); }
/** * Recursively adds the given {@link BundleDescription} and its dependents to the given {@link * Set} * * @param desc the {@link BundleDescription} to compute dependencies for * @param set the {@link Set} to collect results in * @param includeOptional if optional dependencies should be included * @param excludeFragments a collection of <b>fragment</b> bundle symbolic names to exclude from * the dependency resolution */ private static void addBundleAndDependencies( BundleDescription desc, Set<String> set, boolean includeOptional, Set<String> excludeFragments) { if (desc != null && set.add(desc.getSymbolicName())) { BundleSpecification[] required = desc.getRequiredBundles(); for (int i = 0; i < required.length; i++) { if (includeOptional || !required[i].isOptional()) { addBundleAndDependencies( (BundleDescription) required[i].getSupplier(), set, includeOptional, excludeFragments); } } ImportPackageSpecification[] importedPkgs = desc.getImportPackages(); for (int i = 0; i < importedPkgs.length; i++) { ExportPackageDescription exporter = (ExportPackageDescription) importedPkgs[i].getSupplier(); // Continue if the Imported Package is unresolved of the package is optional and don't want // optional packages if (exporter == null || (!includeOptional && Constants.RESOLUTION_OPTIONAL.equals( importedPkgs[i].getDirective(Constants.RESOLUTION_DIRECTIVE)))) { continue; } addBundleAndDependencies(exporter.getExporter(), set, includeOptional, excludeFragments); } BundleDescription[] fragments = desc.getFragments(); for (int i = 0; i < fragments.length; i++) { if (!fragments[i].isResolved()) { continue; } String id = fragments[i].getSymbolicName(); if (!excludeFragments.contains(id)) { addBundleAndDependencies(fragments[i], set, includeOptional, excludeFragments); } } HostSpecification host = desc.getHost(); if (host != null) { addBundleAndDependencies( (BundleDescription) host.getSupplier(), set, includeOptional, excludeFragments); } } }