public void load(BundleSpecification importModel) { this.fID = importModel.getName(); this.reexported = importModel.isExported(); this.optional = importModel.isOptional(); VersionRange versionRange = importModel.getVersionRange(); if (versionRange == null || VersionRange.emptyRange.equals(versionRange)) { this.version = null; match = IMatchRules.NONE; } else { this.version = versionRange.getMinimum() != null ? versionRange.getMinimum().toString() : null; match = PluginBase.getMatchRule(versionRange); } }
if (required[i].getSupplier() != null) { resolvedBundlesExported.put((BundleDescription) required[i].getSupplier(), new Boolean(required[i].isExported())); resolved.remove(required[i].getSupplier()); BundleSpecification[] fragmentRequiredBundles = fragments[i].getRequiredBundles(); for (int j = 0; j < fragmentRequiredBundles.length; j++) { if (resolved.contains(fragmentRequiredBundles[j].getSupplier())) { resolvedBundlesExported.put((BundleDescription) fragmentRequiredBundles[j].getSupplier(), new Boolean(fragmentRequiredBundles[j].isExported())); resolved.remove(fragmentRequiredBundles[j].getSupplier());
private void hackRequireBundleManifestHeader(final BundleDescription bundleDescription, final List<BundleCapability> availableCapabilities, final Attributes mainAttributes) { StringBuilder hackedRequireBundleSB = new StringBuilder(); BundleSpecification[] requiredBundles = bundleDescription.getRequiredBundles(); for (BundleSpecification requiredBundle : requiredBundles) { if (hackedRequireBundleSB.length() > 0) { hackedRequireBundleSB.append(","); } hackedRequireBundleSB.append(requiredBundle.getName() + ";bundle-version=\"" + requiredBundle.getVersionRange() + "\""); if (requiredBundle.isOptional() || !requirementSatisfiable(requiredBundle.getRequirement(), availableCapabilities)) { if (!requiredBundle.isOptional()) { LOGGER.info( "[HACK]: Making Require-Bundle optional in bundle " + bundleDescription.toString() + ": " + hackedRequireBundleSB.toString()); } hackedRequireBundleSB.append(";").append(Constants.RESOLUTION_DIRECTIVE).append(":=") .append("\"") .append(Constants.RESOLUTION_OPTIONAL).append("\""); } } if (hackedRequireBundleSB.length() > 0) { mainAttributes.putValue(Constants.REQUIRE_BUNDLE, hackedRequireBundleSB.toString()); } }
protected void addRequiredBundles(BundleSpecification[] requiredBundles) { for (BundleSpecification bundle : requiredBundles) { if (bundle.isOptional() && !fIncludeOptional) continue; BaseDescription bd = bundle.getSupplier(); // only recursively search statisfied require-bundles if (bd != null && bd instanceof BundleDescription) findDependencies((BundleDescription) bd); } }
protected void addRequireBundleRequirement(ArrayList<IRequirement> reqsDeps, BundleSpecification requiredBundle, ManifestElement[] rawRequireBundleHeader) { final boolean optional = requiredBundle.isOptional(); final boolean greedy; if (optional) greedy = INSTALLATION_GREEDY.equals(getInstallationDirective(requiredBundle.getName(), rawRequireBundleHeader)); else greedy = true; reqsDeps.add(MetadataFactory.createRequirement(CAPABILITY_NS_OSGI_BUNDLE, requiredBundle.getName(), PublisherHelper.fromOSGiVersionRange(requiredBundle.getVersionRange()), null, optional ? 0 : 1, 1, greedy)); }
boolean isOptional() { if (constraint instanceof HostSpecification) return false; return ((BundleSpecification) constraint).isOptional(); } }
it.remove(); if (candidate instanceof BundleSpecification) { if (!fShowOptional && ((BundleSpecification) candidate).isOptional()) continue; desc = (BundleDescription) ((BundleSpecification) candidate).getSupplier(); elements.put(((BundleSpecification) candidate).getName(), candidate); } else if (candidate instanceof BundleDescription) { desc = (BundleDescription) candidate;
int severity = getRequireBundleSeverity(required[i], optional); if (specs[i].getSupplier() == null) { if (desc.getContainingState().getBundle(specs[i].getName(), null) == null) { IMarker marker = report(NLS.bind(PDECoreMessages.BundleErrorReporter_NotExistPDE, bundleID), getPackageLine(header, required[i]), report(NLS.bind(PDECoreMessages.BundleErrorReporter_BundleRangeInvalidInBundleVersion, bundleID + ": " + specs[i].getVersionRange()), //$NON-NLS-1$ getPackageLine(header, required[i]), severity, PDEMarkerFactory.CAT_FATAL);
/** * Returns the set of String bundle names that are in the project's list of required * bundles. * * @return set of required bundle names, possibly empty */ private Set<String> getCurrentBundleNames() { IPluginModelBase base = PluginRegistry.findModel(fProject); if (base != null) { Set<String> bundleNames = new HashSet<>(); BundleSpecification[] reqBundles = base.getBundleDescription().getRequiredBundles(); for (BundleSpecification reqBundle : reqBundles) { bundleNames.add(reqBundle.getName()); } return bundleNames; } return Collections.emptySet(); }
BundleDescription getSupplier(int index) { if (isUsingResolved) return resolvedRequires[index]; return (BundleDescription) requiredBundles[index].getSupplier(); }
BundleConstraint hostRequire = getRequire(newRequires[i].getName()); ResolverBundle resolvedRequire = (ResolverBundle) (hostRequire == null ? null : hostRequire.getSelectedSupplier()); if ((resolvedRequire == null && isResolved()) || (resolvedRequire != null && !newRequires[i].isSatisfiedBy(resolvedRequire.getBundleDescription()))) { result = true; resolver.getState().addResolverError(fragment, ResolverError.FRAGMENT_CONFLICT, newRequires[i].toString(), newRequires[i]);
private void addDependency(State state, String bundleID, Set<String> set) { if (bundleID == null || !set.add(bundleID)) return; BundleDescription desc = state.getBundle(bundleID, null); if (desc == null) return; BundleDescription[] fragments = desc.getFragments(); for (BundleDescription fragment : fragments) { addDependency(state, fragment.getSymbolicName(), set); } BundleSpecification[] specs = desc.getRequiredBundles(); for (BundleSpecification spec : specs) { if (spec.isResolved() && spec.isExported()) { addDependency(state, spec.getName(), set); } } }
if (requiredSpecs != null && requiredSpecs.length > 0) for (int i = 0; i < requiredSpecs.length; i++) if (requiredSpecs[i].isExported()) reExportSet.add(requiredSpecs[i].getName());
boolean isExported(int index) { if (isUsingResolved) return resolvedBundlesExported.get(resolvedRequires[index]).booleanValue(); return requiredBundles[index].isExported(); }
public List<BundleRequirement> getDeclaredRequirements(String namespace) { List<BundleRequirement> result = new ArrayList<BundleRequirement>(); if (namespace == null || BundleRevision.BUNDLE_NAMESPACE.equals(namespace)) { BundleSpecification[] requires = getRequiredBundles(); for (BundleSpecification require : requires) { result.add(require.getRequirement()); } } if (host != null && (namespace == null || BundleRevision.HOST_NAMESPACE.equals(namespace))) { result.add(host.getRequirement()); } if (namespace == null || BundleRevision.PACKAGE_NAMESPACE.equals(namespace)) { ImportPackageSpecification[] imports = getImportPackages(); for (ImportPackageSpecification importPkg : imports) result.add(importPkg.getRequirement()); } GenericSpecification[] genericSpecifications = getGenericRequires(); for (GenericSpecification requirement : genericSpecifications) { if (namespace == null || namespace.equals(requirement.getType())) result.add(requirement.getRequirement()); } return Collections.unmodifiableList(result); }
BundleSpecification[] requiredBundles = bundle.getRequiredBundles(); for (int i = 0; i < requiredBundles.length; i++) if (!requiredBundles[i].isResolved() && !isBundleConstraintResolvable(requiredBundles[i], null, hook)) unsatisfied.add(requiredBundles[i]); ImportPackageSpecification[] packages = bundle.getImportPackages();
/** * This will check through the dependencies of <code>model</code> and install the necessary workspace * plugins if they are required. * * @param model * The model of which we wish the dependencies checked. */ private void checkRequireBundleDependencies(IPluginModelBase model) { final BundleDescription desc = model.getBundleDescription(); if (desc == null) { return; } for (BundleSpecification requiredBundle : desc.getRequiredBundles()) { for (IPluginModelBase workspaceModel : PluginRegistry.getWorkspaceModels()) { if (requiredBundle.isSatisfiedBy(workspaceModel.getBundleDescription())) { installBundle(workspaceModel); break; } } } }
protected void addRequireBundleRequirement(List<IRequirement> reqsDeps, BundleSpecification requiredBundle, ManifestElement[] rawRequireBundleHeader) { final boolean optional = requiredBundle.isOptional(); final boolean greedy; if (optional) { greedy = INSTALLATION_GREEDY.equals(getInstallationDirective(requiredBundle.getName(), rawRequireBundleHeader)); } else { greedy = true; } reqsDeps.add(MetadataFactory.createRequirement(CAPABILITY_NS_OSGI_BUNDLE, requiredBundle.getName(), PublisherHelper.fromOSGiVersionRange(requiredBundle.getVersionRange()), null, optional ? 0 : 1, 1, greedy)); }
boolean isOptional() { if (constraint instanceof HostSpecification) return false; return ((BundleSpecification) constraint).isOptional(); } }
private static void addBundleAndDependencies(BundleDescription desc, Set set, boolean includeOptional) { 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); } 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); } BundleDescription[] fragments = desc.getFragments(); for (int i = 0; i < fragments.length; i++) { if (!fragments[i].isResolved()) continue; String id = fragments[i].getSymbolicName(); if (!"org.eclipse.ui.workbench.compatibility".equals(id)) //$NON-NLS-1$ addBundleAndDependencies(fragments[i], set, includeOptional); } HostSpecification host = desc.getHost(); if (host != null) addBundleAndDependencies((BundleDescription)host.getSupplier(), set, includeOptional); } }