Bug 130602 - Too many trackers in common
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/boot/PlatformURLConnection.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/boot/PlatformURLConnection.java
index 26a4d5a..e4b3570 100644
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/boot/PlatformURLConnection.java
+++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/boot/PlatformURLConnection.java
@@ -63,14 +63,19 @@
public final static boolean DEBUG_CACHE_COPY;
static {
- DebugOptions debugOptions = Activator.getDefault().getDebugOptions();
- if (debugOptions != null) {
- DEBUG = debugOptions.getBooleanOption(OPTION_DEBUG, false);
- DEBUG_CONNECT = debugOptions.getBooleanOption(OPTION_DEBUG_CONNECT, true);
- DEBUG_CACHE_LOOKUP = debugOptions.getBooleanOption(OPTION_DEBUG_CACHE_LOOKUP, true);
- DEBUG_CACHE_COPY = debugOptions.getBooleanOption(OPTION_DEBUG_CACHE_COPY, true);
- } else
+ Activator activator = Activator.getDefault();
+ if (activator == null) {
DEBUG = DEBUG_CONNECT = DEBUG_CACHE_LOOKUP = DEBUG_CACHE_COPY = false;
+ } else {
+ DebugOptions debugOptions = activator.getDebugOptions();
+ if (debugOptions != null) {
+ DEBUG = debugOptions.getBooleanOption(OPTION_DEBUG, false);
+ DEBUG_CONNECT = debugOptions.getBooleanOption(OPTION_DEBUG_CONNECT, true);
+ DEBUG_CACHE_LOOKUP = debugOptions.getBooleanOption(OPTION_DEBUG_CACHE_LOOKUP, true);
+ DEBUG_CACHE_COPY = debugOptions.getBooleanOption(OPTION_DEBUG_CACHE_COPY, true);
+ } else
+ DEBUG = DEBUG_CONNECT = DEBUG_CACHE_LOOKUP = DEBUG_CACHE_COPY = false;
+ }
}
protected PlatformURLConnection(URL url) {
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/Activator.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/Activator.java
index 22ead9c..4799012 100644
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/Activator.java
+++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/Activator.java
@@ -12,10 +12,11 @@
import java.net.URL;
import java.util.*;
-import org.eclipse.core.internal.boot.PlatformURLBaseConnection;
-import org.eclipse.core.internal.boot.PlatformURLHandler;
+import org.eclipse.core.internal.boot.*;
+import org.eclipse.osgi.framework.log.FrameworkLog;
import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.osgi.service.debug.DebugOptions;
+import org.eclipse.osgi.service.localization.BundleLocalization;
import org.eclipse.osgi.service.urlconversion.URLConverter;
import org.osgi.framework.*;
import org.osgi.service.packageadmin.PackageAdmin;
@@ -34,36 +35,53 @@
* Table to keep track of all the URL converter services.
*/
private static Map urlTrackers = new HashMap();
- private static Activator bundle = null;
+ private static BundleContext bundleContext;
+ private static Activator singleton;
private ServiceRegistration platformURLConverterService = null;
private ServiceTracker installLocationTracker = null;
+ private ServiceTracker instanceLocationTracker = null;
private ServiceTracker configLocationTracker = null;
private ServiceTracker bundleTracker = null;
private ServiceTracker debugTracker = null;
+ private ServiceTracker logTracker = null;
+ private ServiceTracker localizationTracker = null;
- /**
- * The bundle context associated this plug-in
+ /*
+ * Returns the singleton for this Activator. Callers should be aware that
+ * this will return null if the bundle is not active.
*/
- private static BundleContext bundleContext;
-
public static Activator getDefault() {
- return bundle;
+ return singleton;
+ }
+ /**
+ * Print a debug message to the console.
+ * Pre-pend the message with the current date and the name of the current thread.
+ */
+ public static void message(String message) {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(new Date(System.currentTimeMillis()));
+ buffer.append(" - ["); //$NON-NLS-1$
+ buffer.append(Thread.currentThread().getName());
+ buffer.append("] "); //$NON-NLS-1$
+ buffer.append(message);
+ System.out.println(buffer.toString());
}
- /**
- * This method is called upon plug-in activation
+ /* (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
bundleContext = context;
- bundle = this;
-
+ singleton = this;
Dictionary urlProperties = new Hashtable();
urlProperties.put("protocol", "platform"); //$NON-NLS-1$ //$NON-NLS-2$
platformURLConverterService = context.registerService(URLConverter.class.getName(), new PlatformURLConverter(), urlProperties);
-
installPlatformURLSupport();
}
+ /*
+ * Return the configuration location service, if available.
+ */
public Location getConfigurationLocation() {
if (configLocationTracker == null) {
Filter filter = null;
@@ -78,6 +96,9 @@
return (Location) configLocationTracker.getService();
}
+ /*
+ * Return the debug options service, if available.
+ */
public DebugOptions getDebugOptions() {
if (debugTracker == null) {
debugTracker = new ServiceTracker(bundleContext, DebugOptions.class.getName(), null);
@@ -85,6 +106,35 @@
}
return (DebugOptions) debugTracker.getService();
}
+
+ /*
+ * Return the framework log service, if available.
+ */
+ public FrameworkLog getFrameworkLog() {
+ if (logTracker == null) {
+ logTracker = new ServiceTracker(bundleContext, FrameworkLog.class.getName(), null);
+ logTracker.open();
+ }
+ return (FrameworkLog) logTracker.getService();
+ }
+
+ /*
+ * Return the instance location service, if available.
+ */
+ public Location getInstanceLocation() {
+ if (instanceLocationTracker == null) {
+ Filter filter = null;
+ try {
+ filter = bundleContext.createFilter(Location.INSTANCE_FILTER);
+ } catch (InvalidSyntaxException e) {
+ // ignore this. It should never happen as we have tested the above format.
+ }
+ instanceLocationTracker = new ServiceTracker(bundleContext, filter, null);
+ instanceLocationTracker.open();
+ }
+ return (Location) instanceLocationTracker.getService();
+ }
+
/**
* Return the resolved bundle with the specified symbolic name.
*
@@ -106,6 +156,9 @@
return null;
}
+ /*
+ * Return the package admin service, if available.
+ */
private PackageAdmin getBundleAdmin() {
if (bundleTracker == null) {
bundleTracker = new ServiceTracker(getContext(), PackageAdmin.class.getName(), null);
@@ -114,6 +167,9 @@
return (PackageAdmin) bundleTracker.getService();
}
+ /*
+ * Return an array of fragments for the given bundle host.
+ */
public Bundle[] getFragments(Bundle host) {
PackageAdmin admin = getBundleAdmin();
if (admin == null)
@@ -121,7 +177,10 @@
return admin.getFragments(host);
}
- public URL getInstallLocation() {
+ /*
+ * Return the install location service if available.
+ */
+ public Location getInstallLocation() {
if (installLocationTracker == null) {
Filter filter = null;
try {
@@ -132,14 +191,51 @@
installLocationTracker = new ServiceTracker(bundleContext, filter, null);
installLocationTracker.open();
}
- return ((Location) installLocationTracker.getService()).getURL();
+ return (Location) installLocationTracker.getService();
}
/**
- * This method is called when the plug-in is stopped
+ * Returns the bundle id of the bundle that contains the provided object, or
+ * <code>null</code> if the bundle could not be determined.
+ */
+ public String getBundleId(Object object) {
+ if (object == null)
+ return null;
+ if (bundleTracker == null) {
+ message("Bundle tracker is not set"); //$NON-NLS-1$
+ return null;
+ }
+ PackageAdmin packageAdmin = (PackageAdmin) bundleTracker.getService();
+ if (packageAdmin == null)
+ return null;
+
+ Bundle source = packageAdmin.getBundle(object.getClass());
+ if (source != null && source.getSymbolicName() != null)
+ return source.getSymbolicName();
+ return null;
+ }
+
+ public ResourceBundle getLocalization(Bundle bundle, String locale) {
+ if (localizationTracker == null) {
+ BundleContext context = Activator.getContext();
+ if (context == null) {
+ message("ResourceTranslator called before plugin is started"); //$NON-NLS-1$
+ return null;
+ }
+ localizationTracker = new ServiceTracker(context, BundleLocalization.class.getName(), null);
+ localizationTracker.open();
+ }
+ BundleLocalization location = (BundleLocalization) localizationTracker.getService();
+ if (location != null)
+ return location.getLocalization(bundle, locale);
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
- CommonOSGiUtils.getDefault().closeServices();
closeURLTrackerServices();
if (platformURLConverterService != null) {
platformURLConverterService.unregister();
@@ -161,9 +257,25 @@
debugTracker.close();
debugTracker = null;
}
+ if (logTracker != null) {
+ logTracker.close();
+ logTracker = null;
+ }
+ if (instanceLocationTracker != null) {
+ instanceLocationTracker.close();
+ instanceLocationTracker = null;
+ }
+ if (localizationTracker != null) {
+ localizationTracker.close();
+ localizationTracker = null;
+ }
bundleContext = null;
+ singleton = null;
}
+ /*
+ * Return this bundle's context.
+ */
static BundleContext getContext() {
return bundleContext;
}
@@ -220,7 +332,9 @@
PlatformURLMetaConnection.startup();
PlatformURLConfigConnection.startup();
- PlatformURLBaseConnection.startup(getInstallLocation());
+ Location service = getInstallLocation();
+ if (service != null)
+ PlatformURLBaseConnection.startup(service.getURL());
Hashtable properties = new Hashtable(1);
properties.put(URLConstants.URL_HANDLER_PROTOCOL, new String[] {PlatformURLHandler.PROTOCOL});
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/CommonMessages.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/CommonMessages.java
index 2f2e519..85944c4 100644
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/CommonMessages.java
+++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/CommonMessages.java
@@ -56,6 +56,8 @@
public static String fileManager_illegalInReadOnlyMode;
public static String fileManager_notOpen;
+ public static String activator_not_available;
+
static {
// load message values from bundle file
reloadMessages();
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/CommonOSGiUtils.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/CommonOSGiUtils.java
deleted file mode 100644
index b4aae6b..0000000
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/CommonOSGiUtils.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.core.internal.runtime;
-
-import java.util.Date;
-import java.util.ResourceBundle;
-import org.eclipse.osgi.framework.log.FrameworkLog;
-import org.eclipse.osgi.service.datalocation.Location;
-import org.eclipse.osgi.service.localization.BundleLocalization;
-import org.osgi.framework.*;
-import org.osgi.service.packageadmin.PackageAdmin;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * The class contains a set of helper methods for the runtime content plugin.
- * The following utility methods are supplied:
- * - provides framework log
- * - provides some bundle discovery funtionality
- * - provides some location services
- *
- * The closeServices() method should be called before the plugin is stopped.
- *
- * This class can only be used if OSGi plugin is available.
- *
- * @since org.eclipse.equinox.common 1.0
- */
-public class CommonOSGiUtils {
- private ServiceTracker logTracker = null;
- private ServiceTracker bundleTracker = null;
- private ServiceTracker instanceLocationTracker = null;
- private ServiceTracker localizationTracker = null;
-
- // OSGI system properties. Copied from EclipseStarter
- public static final String PROP_INSTANCE_AREA = "osgi.instance.area"; //$NON-NLS-1$
-
- private static final CommonOSGiUtils singleton = new CommonOSGiUtils();
-
- public static CommonOSGiUtils getDefault() {
- return singleton;
- }
-
- /**
- * Private constructor to block instance creation.
- */
- private CommonOSGiUtils() {
- super();
- initServices();
- }
-
- /**
- * Print a debug message to the console.
- * Pre-pend the message with the current date and the name of the current thread.
- */
- public static void message(String message) {
- StringBuffer buffer = new StringBuffer();
- buffer.append(new Date(System.currentTimeMillis()));
- buffer.append(" - ["); //$NON-NLS-1$
- buffer.append(Thread.currentThread().getName());
- buffer.append("] "); //$NON-NLS-1$
- buffer.append(message);
- System.out.println(buffer.toString());
- }
-
- private void initServices() {
- BundleContext context = Activator.getContext();
- if (context == null) {
- message("CommonOSGiUtils called before plugin started"); //$NON-NLS-1$
- return;
- }
-
- logTracker = new ServiceTracker(context, FrameworkLog.class.getName(), null);
- logTracker.open();
-
- bundleTracker = new ServiceTracker(context, PackageAdmin.class.getName(), null);
- bundleTracker.open();
-
- // locations
-
- final String FILTER_PREFIX = "(&(objectClass=org.eclipse.osgi.service.datalocation.Location)(type="; //$NON-NLS-1$
- Filter filter = null;
- try {
- filter = context.createFilter(FILTER_PREFIX + PROP_INSTANCE_AREA + "))"); //$NON-NLS-1$
- } catch (InvalidSyntaxException e) {
- // ignore this. It should never happen as we have tested the above format.
- }
- instanceLocationTracker = new ServiceTracker(context, filter, null);
- instanceLocationTracker.open();
- }
-
- void closeServices() {
- if (localizationTracker != null) {
- localizationTracker.close();
- localizationTracker = null;
- }
- if (logTracker != null) {
- logTracker.close();
- logTracker = null;
- }
- if (bundleTracker != null) {
- bundleTracker.close();
- bundleTracker = null;
- }
- if (instanceLocationTracker != null) {
- instanceLocationTracker.close();
- instanceLocationTracker = null;
- }
- }
-
- public FrameworkLog getFrameworkLog() {
- if (logTracker != null)
- return (FrameworkLog) logTracker.getService();
- message("Log tracker is not set"); //$NON-NLS-1$
- return null;
- }
-
- public Bundle[] getFragments(Bundle bundle) {
- if (bundleTracker == null) {
- message("Bundle tracker is not set"); //$NON-NLS-1$
- return null;
- }
- PackageAdmin packageAdmin = (PackageAdmin) bundleTracker.getService();
- if (packageAdmin == null)
- return null;
- return packageAdmin.getFragments(bundle);
- }
-
- public Location getInstanceLocation() {
- if (instanceLocationTracker != null)
- return (Location) instanceLocationTracker.getService();
- else
- return null;
- }
-
- public ResourceBundle getLocalization(Bundle bundle, String locale) {
- if (localizationTracker == null) {
- BundleContext context = Activator.getContext();
- if (context == null) {
- message("ResourceTranslator called before plugin is started"); //$NON-NLS-1$
- return null;
- }
- localizationTracker = new ServiceTracker(context, BundleLocalization.class.getName(), null);
- localizationTracker.open();
- }
- BundleLocalization location = (BundleLocalization) localizationTracker.getService();
- if (location != null)
- return location.getLocalization(bundle, locale);
-
- return null;
- }
-
- /**
- * Returns the bundle id of the bundle that contains the provided object, or
- * <code>null</code> if the bundle could not be determined.
- */
- public String getBundleId(Object object) {
- if (object == null)
- return null;
- if (bundleTracker == null) {
- message("Bundle tracker is not set"); //$NON-NLS-1$
- return null;
- }
- PackageAdmin packageAdmin = (PackageAdmin) bundleTracker.getService();
- if (packageAdmin == null)
- return null;
-
- Bundle source = packageAdmin.getBundle(object.getClass());
- if (source != null && source.getSymbolicName() != null)
- return source.getSymbolicName();
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/DataArea.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/DataArea.java
index 6eaf5f6..792256a 100644
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/DataArea.java
+++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/DataArea.java
@@ -36,7 +36,10 @@
protected void assertLocationInitialized() throws IllegalStateException {
if (location != null && initialized)
return;
- Location service = CommonOSGiUtils.getDefault().getInstanceLocation();
+ Activator activator = Activator.getDefault();
+ if (activator == null)
+ throw new IllegalStateException(CommonMessages.activator_not_available);
+ Location service = activator.getInstanceLocation();
if (service == null)
throw new IllegalStateException(CommonMessages.meta_noDataModeSpecified);
try {
@@ -64,7 +67,7 @@
}
public IPath getLogLocation() throws IllegalStateException {
- return new Path(CommonOSGiUtils.getDefault().getFrameworkLog().getFile().getAbsolutePath());
+ return new Path(Activator.getDefault().getFrameworkLog().getFile().getAbsolutePath());
}
/**
@@ -118,7 +121,9 @@
// set the log file location now that we created the data area
IPath path = location.append(F_META_AREA).append(F_LOG);
try {
- CommonOSGiUtils.getDefault().getFrameworkLog().setFile(path.toFile(), true);
+ Activator activator = Activator.getDefault();
+ if (activator != null)
+ activator.getFrameworkLog().setFile(path.toFile(), true);
} catch (IOException e) {
e.printStackTrace();
}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/FindSupport.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/FindSupport.java
index caa5aaf..2971ac1 100644
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/FindSupport.java
+++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/FindSupport.java
@@ -214,7 +214,10 @@
}
private static URL findInFragments(Bundle b, IPath filePath) {
- Bundle[] fragments = CommonOSGiUtils.getDefault().getFragments(b);
+ Activator activator = Activator.getDefault();
+ if (activator == null)
+ return null;
+ Bundle[] fragments = activator.getFragments(b);
if (fragments == null)
return null;
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLConfigConnection.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLConfigConnection.java
index eb8018c..a42711c 100644
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLConfigConnection.java
+++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLConfigConnection.java
@@ -43,7 +43,10 @@
throw new IOException(NLS.bind(CommonMessages.url_badVariant, url.toString()));
String path = spec.substring(CONFIG.length() + 1);
// resolution takes parent configuration into account (if it exists)
- Location localConfig = Activator.getDefault().getConfigurationLocation();
+ Activator activator = Activator.getDefault();
+ if (activator == null)
+ throw new IOException(CommonMessages.activator_not_available);
+ Location localConfig = activator.getConfigurationLocation();
Location parentConfig = localConfig.getParentLocation();
// assume we will find the file locally
URL localURL = new URL(localConfig.getURL(), path);
@@ -80,7 +83,7 @@
* @see java.net.URLConnection#getOutputStream()
*/
public OutputStream getOutputStream() throws IOException {
- if (parentConfiguration || Activator.getDefault().getConfigurationLocation().isReadOnly())
+ if (parentConfiguration || Activator.getDefault() == null || Activator.getDefault().getConfigurationLocation().isReadOnly())
throw new UnknownServiceException(NLS.bind(CommonMessages.url_noOutput, url));
//This is not optimal but connection is a private instance variable in the super-class.
URL resolved = getResolvedURL();
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLFragmentConnection.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLFragmentConnection.java
index e9564f5..de3053c 100644
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLFragmentConnection.java
+++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLFragmentConnection.java
@@ -53,7 +53,10 @@
int ix = spec.indexOf("/", FRAGMENT.length() + 1); //$NON-NLS-1$
String ref = ix == -1 ? spec.substring(FRAGMENT.length() + 1) : spec.substring(FRAGMENT.length() + 1, ix);
String id = getId(ref);
- target = Activator.getDefault().getBundle(id);
+ Activator activator = Activator.getDefault();
+ if (activator == null)
+ throw new IOException(CommonMessages.activator_not_available);
+ target = activator.getBundle(id);
if (target == null)
throw new IOException(NLS.bind(CommonMessages.url_resolveFragment, url));
URL result = target.getEntry("/"); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLMetaConnection.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLMetaConnection.java
index 74d54df..7ebad21 100644
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLMetaConnection.java
+++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLMetaConnection.java
@@ -42,7 +42,10 @@
int ix = spec.indexOf("/", META.length() + 1); //$NON-NLS-1$
String ref = ix == -1 ? spec.substring(META.length() + 1) : spec.substring(META.length() + 1, ix);
String id = getId(ref);
- target = Activator.getDefault().getBundle(id);
+ Activator activator = Activator.getDefault();
+ if (activator == null)
+ throw new IOException(CommonMessages.activator_not_available);
+ target = activator.getBundle(id);
if (target == null)
throw new IOException(NLS.bind(CommonMessages.url_resolvePlugin, url.toString()));
IPath path = MetaDataKeeper.getMetaArea().getStateLocation(target);
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLPluginConnection.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLPluginConnection.java
index 7ff6d0b..ccb5686 100644
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLPluginConnection.java
+++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PlatformURLPluginConnection.java
@@ -53,7 +53,10 @@
int ix = spec.indexOf("/", PLUGIN.length() + 1); //$NON-NLS-1$
String ref = ix == -1 ? spec.substring(PLUGIN.length() + 1) : spec.substring(PLUGIN.length() + 1, ix);
String id = getId(ref);
- target = Activator.getDefault().getBundle(id);
+ Activator activator = Activator.getDefault();
+ if (activator == null)
+ throw new IOException(CommonMessages.activator_not_available);
+ target = activator.getBundle(id);
if (target == null)
throw new IOException(NLS.bind(CommonMessages.url_resolvePlugin, url));
if (ix == -1 || (ix + 1) >= spec.length())
@@ -87,7 +90,10 @@
int ix = spec.indexOf("/", PLUGIN.length() + 1); //$NON-NLS-1$
String ref = ix == -1 ? spec.substring(PLUGIN.length() + 1) : spec.substring(PLUGIN.length() + 1, ix);
String id = getId(ref);
- target = Activator.getDefault().getBundle(id);
+ Activator activator = Activator.getDefault();
+ if (activator == null)
+ throw new IOException(CommonMessages.activator_not_available);
+ target = activator.getBundle(id);
if (target == null)
throw new IOException(NLS.bind(CommonMessages.url_resolvePlugin, url));
}
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ResourceTranslator.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ResourceTranslator.java
index f12aebc..91a7070 100644
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ResourceTranslator.java
+++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/ResourceTranslator.java
@@ -60,7 +60,7 @@
public static ResourceBundle getResourceBundle(Bundle bundle) throws MissingResourceException {
if (hasRuntime21(bundle))
return ResourceBundle.getBundle("plugin", Locale.getDefault(), createTempClassloader(bundle)); //$NON-NLS-1$
- return CommonOSGiUtils.getDefault().getLocalization(bundle, null);
+ return Activator.getDefault().getLocalization(bundle, null);
}
private static boolean hasRuntime21(Bundle b) {
@@ -90,7 +90,10 @@
}
private static void addFragments(Bundle host, ArrayList classpath) {
- Bundle[] fragments = CommonOSGiUtils.getDefault().getFragments(host);
+ Activator activator = Activator.getDefault();
+ if (activator == null)
+ return;
+ Bundle[] fragments = activator.getFragments(host);
if (fragments == null)
return;
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/commonMessages.properties b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/commonMessages.properties
index 601ce7a..f493f4f 100644
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/commonMessages.properties
+++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/commonMessages.properties
@@ -50,3 +50,4 @@
url_resolveFragment = Unable to resolve fragment \"{0}\".
url_resolvePlugin = Unable to resolve plug-in \"{0}\".
+activator_not_available = The bundle activator for the org.eclipse.equinox.common bundle is not available.
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SafeRunner.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SafeRunner.java
index b86d3ce..2834f28 100644
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SafeRunner.java
+++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SafeRunner.java
@@ -45,7 +45,10 @@
private static void handleException(ISafeRunnable code, Throwable e) {
if (!(e instanceof OperationCanceledException)) {
// try to obtain the correct plug-in id for the bundle providing the safe runnable
- String pluginId = CommonOSGiUtils.getDefault().getBundleId(code);
+ Activator activator = Activator.getDefault();
+ String pluginId = null;
+ if (activator != null)
+ pluginId = activator.getBundleId(code);
if (pluginId == null)
pluginId = IRuntimeConstants.NAME;
String message = NLS.bind(CommonMessages.meta_pluginProblems, pluginId);