Skip to content

Commit 26e4f1f

Browse files
committed
Remove unused reference to PlatformAdmin / do not use PackageAdmin
PlatformAdmin + PackageAdmin are part of the old legacy Resolver API and should not be used anymore.
1 parent fccd7f4 commit 26e4f1f

File tree

4 files changed

+21
-61
lines changed

4 files changed

+21
-61
lines changed

update/org.eclipse.update.configurator/META-INF/MANIFEST.MF

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: %pluginName
44
Bundle-SymbolicName: org.eclipse.update.configurator; singleton:=true
5-
Bundle-Version: 3.5.800.qualifier
5+
Bundle-Version: 3.5.900.qualifier
66
Bundle-Activator: org.eclipse.update.internal.configurator.ConfigurationActivator
77
Bundle-Vendor: %providerName
88
Bundle-Localization: plugin
99
Export-Package: org.eclipse.update.configurator,
1010
org.eclipse.update.internal.configurator;x-friends:="org.eclipse.update.core",
1111
org.eclipse.update.internal.configurator.branding;x-friends:="org.eclipse.update.core"
12-
Require-Bundle: org.eclipse.equinox.common;bundle-version="[3.18.0,4.0.0)",
13-
org.eclipse.osgi;bundle-version="[3.2.0,4.0.0)",
14-
org.eclipse.core.runtime;bundle-version="3.29.0"
12+
Require-Bundle: org.eclipse.core.runtime;bundle-version="3.29.0"
1513
Bundle-RequiredExecutionEnvironment: JavaSE-17
1614
Import-Package: javax.xml.parsers,
1715
org.w3c.dom,

update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/FeatureEntry.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,22 @@
1313
*******************************************************************************/
1414
package org.eclipse.update.internal.configurator;
1515

16-
import java.net.*;
16+
import java.net.MalformedURLException;
17+
import java.net.URL;
18+
import java.net.URLClassLoader;
1719
import java.util.ArrayList;
1820
import java.util.MissingResourceException;
1921
import java.util.ResourceBundle;
2022

21-
import org.eclipse.core.runtime.*;
22-
import org.eclipse.update.configurator.*;
23-
import org.eclipse.update.internal.configurator.branding.*;
24-
import org.osgi.framework.*;
25-
import org.w3c.dom.*;
23+
import org.eclipse.core.runtime.IBundleGroup;
24+
import org.eclipse.core.runtime.Platform;
25+
import org.eclipse.update.configurator.IPlatformConfiguration;
26+
import org.eclipse.update.internal.configurator.branding.AboutInfo;
27+
import org.eclipse.update.internal.configurator.branding.IBundleGroupConstants;
28+
import org.eclipse.update.internal.configurator.branding.IProductConstants;
29+
import org.osgi.framework.Bundle;
30+
import org.w3c.dom.Document;
31+
import org.w3c.dom.Element;
2632

2733

2834
/**
@@ -197,7 +203,7 @@ public Bundle[] getBundles() {
197203
ArrayList<Bundle> bundles = new ArrayList<>(plugins.size());
198204
for (PluginEntry plugin : plugins) {
199205
// get the highest version for the plugin
200-
Bundle bundle = Utils.getBundle(plugin.getPluginIdentifier());
206+
Bundle bundle = Platform.getBundle(plugin.getPluginIdentifier());
201207
if (bundle != null) {
202208
bundles.add(bundle);
203209
}
@@ -357,11 +363,11 @@ private void fullParse() {
357363
}
358364

359365
public Bundle getDefiningBundle() {
360-
return Utils.getBundle(getFeaturePluginIdentifier());
366+
return Platform.getBundle(getFeaturePluginIdentifier());
361367
}
362368

363369
public boolean hasBranding() {
364370
String bundleId = getFeaturePluginIdentifier();
365-
return bundleId != null && Utils.getBundle(bundleId) != null;
371+
return bundleId != null && Platform.getBundle(bundleId) != null;
366372
}
367373
}

update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/Utils.java

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,16 @@
2626
import org.eclipse.core.runtime.IPath;
2727
import org.eclipse.core.runtime.IStatus;
2828
import org.eclipse.core.runtime.MultiStatus;
29+
import org.eclipse.core.runtime.Platform;
2930
import org.eclipse.core.runtime.Status;
3031
import org.eclipse.osgi.framework.log.FrameworkLog;
3132
import org.eclipse.osgi.framework.log.FrameworkLogEntry;
3233
import org.eclipse.osgi.service.datalocation.Location;
3334
import org.eclipse.osgi.service.environment.EnvironmentInfo;
34-
import org.eclipse.osgi.service.resolver.PlatformAdmin;
3535
import org.osgi.framework.Bundle;
3636
import org.osgi.framework.BundleContext;
3737
import org.osgi.framework.Filter;
3838
import org.osgi.framework.InvalidSyntaxException;
39-
import org.osgi.framework.ServiceReference;
4039
import org.osgi.service.packageadmin.PackageAdmin;
4140
import org.osgi.util.tracker.ServiceTracker;
4241

@@ -144,7 +143,7 @@ public static void log(IStatus status) {
144143
* platform to be running.
145144
*/
146145
public static boolean isRunning() {
147-
Bundle bundle = getBundle(PI_OSGI);
146+
Bundle bundle = Platform.getBundle(PI_OSGI);
148147
return bundle == null ? false : (bundle.getState() & (Bundle.ACTIVE | Bundle.STARTING)) != 0;
149148
}
150149

@@ -200,49 +199,6 @@ public static String getNL() {
200199
return getContext().getProperty(PROP_NL);
201200
}
202201

203-
/**
204-
* Returns a number that changes whenever the set of installed plug-ins
205-
* changes. This can be used for invalidating caches that are based on
206-
* the set of currently installed plug-ins. (e.g. extensions)
207-
*
208-
* @see PlatformAdmin#getState()
209-
* @see org.eclipse.osgi.service.resolver.State#getTimeStamp()
210-
*/
211-
public static long getStateStamp() {
212-
ServiceReference<PlatformAdmin> platformAdminReference = getContext().getServiceReference(PlatformAdmin.class);
213-
if (platformAdminReference == null) {
214-
return -1;
215-
}
216-
PlatformAdmin admin = getContext().getService(platformAdminReference);
217-
return admin == null ? -1 : admin.getState(false).getTimeStamp();
218-
}
219-
220-
/**
221-
* Return the resolved bundle with the specified symbolic name.
222-
*
223-
* @see PackageAdmin#getBundles(String, String)
224-
*/
225-
public static synchronized Bundle getBundle(String symbolicName) {
226-
if (bundleTracker == null) {
227-
bundleTracker = new ServiceTracker<>(getContext(), PackageAdmin.class, null);
228-
bundleTracker.open();
229-
}
230-
PackageAdmin admin = bundleTracker.getService();
231-
if (admin == null) {
232-
return null;
233-
}
234-
Bundle[] bundles = admin.getBundles(symbolicName, null);
235-
if (bundles == null) {
236-
return null;
237-
}
238-
//Return the first bundle that is not installed or uninstalled
239-
for (Bundle bundle : bundles) {
240-
if ((bundle.getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) {
241-
return bundle;
242-
}
243-
}
244-
return null;
245-
}
246202

247203
/*
248204
* Return the bundle context for this bundle.

update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/branding/IniFileReader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
import org.eclipse.core.runtime.FileLocator;
2929
import org.eclipse.core.runtime.IPath;
3030
import org.eclipse.core.runtime.IStatus;
31+
import org.eclipse.core.runtime.Platform;
3132
import org.eclipse.core.runtime.Status;
3233
import org.eclipse.osgi.util.NLS;
3334
import org.eclipse.update.internal.configurator.Messages;
34-
import org.eclipse.update.internal.configurator.Utils;
3535
import org.osgi.framework.Bundle;
3636
import org.osgi.framework.Constants;
3737

@@ -95,7 +95,7 @@ public IStatus load() {
9595
}
9696

9797
// attempt to locate the corresponding plugin
98-
bundle = Utils.getBundle(pluginId);
98+
bundle = Platform.getBundle(pluginId);
9999
if (bundle == null || bundle.getState() == Bundle.UNINSTALLED || bundle.getState() == Bundle.INSTALLED) {
100100
bundle = null; // make it null for other test down the road
101101
String message = NLS.bind(Messages.IniFileReader_MissingDesc, featureId);

0 commit comments

Comments
 (0)