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}); }
/** * This will iterate over the "Export-Package" manifest header of the given bundle and search a * bundle corresponding to the given qualified class name. * * <p>For example, if the qualified name we're given is "org.eclipse.acceleo.sample.Test", we'll * search for a bundle exporting the package "org.eclipse.acceleo.sample". * * @param model The bundle model that is to be checked. * @param qualifiedName Qualified name of the class we search the exported package of. * @return <code>true</code> iff <code>model</code> has an entry for a package corresponding to * <code>qualifiedName</code>. */ private static boolean hasCorrespondingExportPackage( IPluginModelBase model, String qualifiedName) { String packageName = ""; // $NON-NLS-1$ final int end = qualifiedName.lastIndexOf('.'); if (end != -1) { packageName = qualifiedName.substring(0, end); } for (ExportPackageDescription exported : model.getBundleDescription().getExportPackages()) { if (packageName.startsWith(exported.getName())) { return true; } } return false; }
/** * 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); } } }
protected Object[] findCallees(IPluginModelBase model) { BundleDescription desc = model.getBundleDescription(); if (desc == null) return new Object[0]; fFragmentDescription = null; HostSpecification spec = desc.getHost(); if (spec != null) { fFragmentDescription = desc; Object[] fragmentDependencies = getDependencies(desc); BaseDescription host = spec.getSupplier(); if (host instanceof BundleDescription) { BundleDescription hostDesc = (BundleDescription) host; // check to see if the host is already included as a dependency. If so, we don't need to // include the host manually. for (int i = 0; i < fragmentDependencies.length; i++) { BundleDescription dependency = null; if (fragmentDependencies[i] instanceof BundleSpecification) dependency = ((BundleSpecification) fragmentDependencies[i]).getBundle(); else if (fragmentDependencies[i] instanceof ImportPackageSpecification) { ExportPackageDescription epd = (ExportPackageDescription) ((ImportPackageSpecification) fragmentDependencies[i]).getSupplier(); if (epd != null) dependency = epd.getSupplier(); } if (dependency != null && dependency.equals(hostDesc)) return fragmentDependencies; } // host not included as dependency, include it manually. Object[] result = new Object[fragmentDependencies.length + 1]; result[0] = hostDesc; System.arraycopy(fragmentDependencies, 0, result, 1, fragmentDependencies.length); return result; } return fragmentDependencies; } return getDependencies(desc); }
public void checkWiringState_1() { ExportPackageDescription[] exports = bundle_1.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.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); } else 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("javax.xml.parsers")) { assertNotNull("Package [javax] is not wired when it should be ", exp.getExporter()); assertEquals("Package [javax] is wired incorrectly ", exp.getExporter(), bundle_6); } } // end for } // end method
public ExportPackageInfo(ExportPackageDescription exportPackageDescription) { name = exportPackageDescription.getName(); version = exportPackageDescription.getVersion().toString(); attributes = exportPackageDescription.getAttributes(); directives = exportPackageDescription.getDirectives(); }