From 2fcf9baa76e556a3da92b035f0128a6e02bc5bb5 Mon Sep 17 00:00:00 2001 From: Todor Boev Date: Fri, 5 May 2017 17:03:05 +0300 Subject: Bug 486279 - Added a utility method to search for BundleInfo Added a utility method to search for BundleInfo entries by name/version rather than by Object.equals() Change-Id: Ib31c8672834e7beaa274d68e20065acef9a31f11 Signed-off-by: Todor Boev --- .../equinox/internal/p2/touchpoint/eclipse/Util.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java index 52d27b2dc..0f803ccdd 100644 --- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java +++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/Util.java @@ -22,6 +22,7 @@ import org.eclipse.core.runtime.*; import org.eclipse.equinox.frameworkadmin.BundleInfo; import org.eclipse.equinox.internal.p2.core.helpers.*; import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability; +import org.eclipse.equinox.internal.provisional.frameworkadmin.ConfigData; import org.eclipse.equinox.p2.core.*; import org.eclipse.equinox.p2.engine.IProfile; import org.eclipse.equinox.p2.metadata.*; @@ -206,6 +207,23 @@ public class Util { return bundleInfo; } + public static BundleInfo findBundleInfo(ConfigData config, IInstallableUnit unit) { + // Construct a partial BundleInfo from the IU capabilities. + BundleInfo bundleInfo = Util.createBundleInfo(null, unit); + + // Find the actual fully populated BundleInfo used by the runtime. + BundleInfo[] bundles = config.getBundles(); + for (BundleInfo bundle : bundles) { + // Can't use BundleInfol.equals(), because bundleInfo is only partially populated. + if (bundleInfo.getSymbolicName().equals(bundle.getSymbolicName()) + && bundleInfo.getVersion().equals(bundle.getVersion())) { + return bundle; + } + } + + return null; + } + private static String getFragmentHost(IInstallableUnit unit, String fragmentName) { Collection requires = unit.getRequirements(); for (IRequirement iRequirement : requires) { -- cgit v1.2.3