From 4e1581e76144ffca94363f57dd88c6587aa6b7f5 Mon Sep 17 00:00:00 2001 From: Alexander Kurtakov Date: Thu, 30 Jan 2020 22:28:47 +0200 Subject: Use BundleStartLevel. Instead of deprecated StartLevel service. Change-Id: Id6ceb4bbda29f8dae5ec8b66797b6b85481b762c Signed-off-by: Alexander Kurtakov --- .../META-INF/MANIFEST.MF | 1 + .../frameworkadmin/equinox/EquinoxManipulatorImpl.java | 7 +++---- .../META-INF/MANIFEST.MF | 1 + .../equinox/internal/simpleconfigurator/ConfigApplier.java | 10 ++-------- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/bundles/org.eclipse.equinox.frameworkadmin.equinox/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.frameworkadmin.equinox/META-INF/MANIFEST.MF index 6e88f7041..548cb55b6 100644 --- a/bundles/org.eclipse.equinox.frameworkadmin.equinox/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.frameworkadmin.equinox/META-INF/MANIFEST.MF @@ -14,6 +14,7 @@ Import-Package: org.eclipse.equinox.frameworkadmin;version="[2.0.0,3.0.0)", org.eclipse.osgi.service.resolver;version="1.1.0";resolution:=optional, org.eclipse.osgi.util;version="1.1.0", org.osgi.framework;version="1.3.0", + org.osgi.framework.startlevel;version="1.0.0", org.osgi.service.log;version="1.3.0", org.osgi.service.startlevel;version="1.0.0", org.osgi.util.tracker;version="1.3.0" diff --git a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxManipulatorImpl.java b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxManipulatorImpl.java index f982e3f25..5f618055c 100644 --- a/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxManipulatorImpl.java +++ b/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxManipulatorImpl.java @@ -28,6 +28,7 @@ import org.eclipse.osgi.service.datalocation.Location; import org.eclipse.osgi.service.resolver.PlatformAdmin; import org.eclipse.osgi.util.NLS; import org.osgi.framework.*; +import org.osgi.framework.startlevel.BundleStartLevel; import org.osgi.service.log.LogService; import org.osgi.service.startlevel.StartLevel; import org.osgi.util.tracker.ServiceTracker; @@ -308,8 +309,6 @@ public class EquinoxManipulatorImpl implements Manipulator { } // 2. Create a Manipulator object fully initialized to the current running fw. - ServiceReference reference = context.getServiceReference(StartLevel.class); - StartLevel startLevel = context.getService(reference); Bundle[] bundles = context.getBundles(); BundleInfo[] bInfos = new BundleInfo[bundles.length]; for (int i = 0; i < bundles.length; i++) { @@ -323,8 +322,8 @@ public class EquinoxManipulatorImpl implements Manipulator { bInfos[i] = new BundleInfo(bundles[i].getSymbolicName(), bundles[i].getHeaders("").get(Constants.BUNDLE_VERSION), //$NON-NLS-1$ FileLocator.getBundleFile(bundles[i]).getAbsoluteFile().toURI(), - startLevel.getBundleStartLevel(bundles[i]), - startLevel.isBundlePersistentlyStarted(bundles[i])); + bundles[i].adapt(BundleStartLevel.class).getStartLevel(), + bundles[i].adapt(BundleStartLevel.class).isPersistentlyStarted()); } } catch (IOException e) { e.printStackTrace(); diff --git a/bundles/org.eclipse.equinox.simpleconfigurator/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.simpleconfigurator/META-INF/MANIFEST.MF index cf631cccd..d8a8d0875 100644 --- a/bundles/org.eclipse.equinox.simpleconfigurator/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.simpleconfigurator/META-INF/MANIFEST.MF @@ -11,6 +11,7 @@ Import-Package: org.eclipse.osgi.framework.console;version="1.0.0";resolution:=o org.eclipse.osgi.service.datalocation;version="1.0.0";resolution:=optional, org.osgi.framework;version="1.3.0", org.osgi.framework.namespace;version="1.0.0", + org.osgi.framework.startlevel;version="1.0.0", org.osgi.framework.wiring;version="1.2.0", org.osgi.resource;version="1.0.0", org.osgi.service.packageadmin;version="1.2.0", diff --git a/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/ConfigApplier.java b/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/ConfigApplier.java index 579ca26e8..f66da5081 100644 --- a/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/ConfigApplier.java +++ b/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/ConfigApplier.java @@ -22,11 +22,11 @@ import java.util.concurrent.CountDownLatch; import org.eclipse.equinox.internal.simpleconfigurator.utils.*; import org.osgi.framework.*; import org.osgi.framework.namespace.*; +import org.osgi.framework.startlevel.BundleStartLevel; import org.osgi.framework.wiring.*; import org.osgi.resource.Namespace; import org.osgi.resource.Requirement; import org.osgi.service.packageadmin.PackageAdmin; -import org.osgi.service.startlevel.StartLevel; class ConfigApplier { private static final String LAST_BUNDLES_INFO = "last.bundles.info"; //$NON-NLS-1$ @@ -34,7 +34,6 @@ class ConfigApplier { private final BundleContext manipulatingContext; private final PackageAdmin packageAdminService; - private final StartLevel startLevelService; private final FrameworkWiring frameworkWiring; private final boolean runningOnEquinox; private final boolean inDevMode; @@ -54,11 +53,6 @@ class ConfigApplier { throw new IllegalStateException("No PackageAdmin service is available."); //$NON-NLS-1$ packageAdminService = manipulatingContext.getService(packageAdminRef); - ServiceReference startLevelRef = manipulatingContext.getServiceReference(StartLevel.class); - if (startLevelRef == null) - throw new IllegalStateException("No StartLevelService service is available."); //$NON-NLS-1$ - startLevelService = manipulatingContext.getService(startLevelRef); - frameworkWiring = manipulatingContext.getBundle(Constants.SYSTEM_BUNDLE_LOCATION).adapt(FrameworkWiring.class); } @@ -367,7 +361,7 @@ class ConfigApplier { continue; try { - startLevelService.setBundleStartLevel(current, startLevel); + current.adapt(BundleStartLevel.class).setStartLevel(startLevel); } catch (IllegalArgumentException ex) { Utils.log(4, null, null, "Failed to set start level of Bundle:" + element, ex); //$NON-NLS-1$ } -- cgit v1.2.3