Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDJ Houghton2006-03-21 11:38:42 +0000
committerDJ Houghton2006-03-21 11:38:42 +0000
commitc2e02221b1f3968729fa7174047eae740a522f00 (patch)
tree6b6a9c21bb1d02cba5b3383ec4b1ce9f70f88567 /bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/Activator.java
parentfc9b261a8b100bd2dd52171bb0b6f46bcc03ea26 (diff)
downloadrt.equinox.bundles-c2e02221b1f3968729fa7174047eae740a522f00.tar.gz
rt.equinox.bundles-c2e02221b1f3968729fa7174047eae740a522f00.tar.xz
rt.equinox.bundles-c2e02221b1f3968729fa7174047eae740a522f00.zip
Bug 129615 - Preferences should optionally depend on the registryv20060320b
Diffstat (limited to 'bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/Activator.java')
-rw-r--r--bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/Activator.java35
1 files changed, 17 insertions, 18 deletions
diff --git a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/Activator.java b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/Activator.java
index 39b0dedeb..4e9c54154 100644
--- a/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/Activator.java
+++ b/bundles/org.eclipse.equinox.preferences/src/org/eclipse/core/internal/preferences/Activator.java
@@ -57,7 +57,9 @@ public class Activator implements BundleActivator, ServiceTrackerCustomizer {
PreferencesOSGiUtils.getDefault().openServices();
preferencesService = bundleContext.registerService(IPreferencesService.class.getName(), PreferencesService.getDefault(), new Hashtable());
osgiPreferencesService = bundleContext.registerService(org.osgi.service.prefs.PreferencesService.class.getName(), new OSGiPreferencesServiceManager(bundleContext), null);
- registerServices();
+ // use the string for the class name here in case the registry isn't around
+ registryServiceTracker = new ServiceTracker(bundleContext, "org.eclipse.core.runtime.IExtensionRegistry", this); //$NON-NLS-1$
+ registryServiceTracker.open();
}
/* (non-Javadoc)
@@ -84,13 +86,13 @@ public class Activator implements BundleActivator, ServiceTrackerCustomizer {
return bundleContext;
}
- private void registerServices() {
- if (registryServiceTracker == null) {
- // use the string for the class name here in case the registry isn't around
- registryServiceTracker = new ServiceTracker(bundleContext, "org.eclipse.core.runtime.IExtensionRegistry", this); //$NON-NLS-1$
- registryServiceTracker.open();
- }
- Object service = registryServiceTracker.getService();
+ /* (non-Javadoc)
+ * @see org.osgi.util.tracker.ServiceTrackerCustomizer#addingService(org.osgi.framework.ServiceReference)
+ */
+ public synchronized Object addingService(ServiceReference reference) {
+ Object service = bundleContext.getService(reference);
+ // this check is important as it avoids early loading of PreferenceServiceRegistryHelper and allows
+ // this bundle to operate with out necessarily resolving against the registry
if (service != null) {
try {
Object helper = new PreferenceServiceRegistryHelper(PreferencesService.getDefault(), service);
@@ -98,20 +100,17 @@ public class Activator implements BundleActivator, ServiceTrackerCustomizer {
} catch (Exception e) {
RuntimeLog.log(new Status(IStatus.ERROR, PI_PREFERENCES, 0, PrefsMessages.noRegistry, e));
} catch (NoClassDefFoundError error) {
- // TODO: Verify behaviour. I think this catch should not be needed since we should never see the
+ // Normally this catch would not be needed since we should never see the
// IExtensionRegistry service without resolving against registry.
- RuntimeLog.log(new Status(IStatus.ERROR, PI_PREFERENCES, 0, PrefsMessages.noRegistry, error));
+ // However, the check is very lenient with split packages and this can happen when
+ // the preferences bundle is already resolved at the time the registry bundle is installed.
+ // For this case we ignore the error. When refreshed the bundle will be rewired correctly.
+ // null is returned because we don't want to track this particular service reference.
+ return null;
}
}
- }
-
- /* (non-Javadoc)
- * @see org.osgi.util.tracker.ServiceTrackerCustomizer#addingService(org.osgi.framework.ServiceReference)
- */
- public synchronized Object addingService(ServiceReference reference) {
- registerServices();
//return the registry service so we track it
- return bundleContext.getService(reference);
+ return service;
}
/* (non-Javadoc)

Back to the top