Bug 117154 uniform API for obtaining the 'default' extension registry
diff --git a/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentOSGiUtils.java b/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentOSGiUtils.java
index e2bdc59..71b9988 100644
--- a/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentOSGiUtils.java
+++ b/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentOSGiUtils.java
@@ -11,7 +11,6 @@
package org.eclipse.core.internal.content;
import javax.xml.parsers.SAXParserFactory;
-import org.eclipse.equinox.registry.IExtensionRegistry;
import org.eclipse.osgi.service.debug.DebugOptions;
import org.osgi.framework.BundleContext;
import org.osgi.util.tracker.ServiceTracker;
@@ -23,7 +22,6 @@
* @since org.eclipse.core.contenttype 1.0
*/
public class ContentOSGiUtils {
- private ServiceTracker registryTracker = null;
private ServiceTracker parserTracker = null;
private ServiceTracker debugTracker = null;
@@ -48,9 +46,6 @@
return;
}
- registryTracker = new ServiceTracker(context, IExtensionRegistry.class.getName(), null);
- registryTracker.open();
-
parserTracker = new ServiceTracker(context, "javax.xml.parsers.SAXParserFactory", null); //$NON-NLS-1$
parserTracker.open();
@@ -59,11 +54,6 @@
}
void closeServices() {
- if (registryTracker != null) {
- registryTracker.close();
- registryTracker = null;
- }
-
if (parserTracker != null) {
parserTracker.close();
parserTracker = null;
@@ -74,13 +64,6 @@
}
}
- public IExtensionRegistry getExtensionRegistry() {
- if (registryTracker != null)
- return (IExtensionRegistry) registryTracker.getService();
- ContentMessages.message("Registry tracker is not set"); //$NON-NLS-1$
- return null;
- }
-
public SAXParserFactory getFactory() {
if (parserTracker == null) {
ContentMessages.message("SAX tracker is not set"); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentTypeBuilder.java b/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentTypeBuilder.java
index ed4e6b6..2783ba7 100644
--- a/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentTypeBuilder.java
+++ b/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentTypeBuilder.java
@@ -181,7 +181,7 @@
* org.eclipse.core.contenttype.contentTypes
*/
protected IConfigurationElement[] getConfigurationElements() {
- IExtensionRegistry registry = ContentOSGiUtils.getDefault().getExtensionRegistry();
+ IExtensionRegistry registry = RegistryFactory.getRegistry();
IConfigurationElement[] oldConfigElements = emptyConfArray;
IConfigurationElement[] newConfigElements = emptyConfArray;
// "old" extenstion point
diff --git a/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentTypeManager.java b/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentTypeManager.java
index 252efe7..42143f8 100644
--- a/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentTypeManager.java
+++ b/bundles/org.eclipse.core.contenttype/src/org/eclipse/core/internal/content/ContentTypeManager.java
@@ -15,8 +15,7 @@
import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.content.*;
import org.eclipse.core.runtime.preferences.*;
-import org.eclipse.equinox.registry.IRegistryChangeEvent;
-import org.eclipse.equinox.registry.IRegistryChangeListener;
+import org.eclipse.equinox.registry.*;
public class ContentTypeManager extends ContentTypeMatcher implements IContentTypeManager, IRegistryChangeListener {
private static ContentTypeManager instance;
@@ -46,7 +45,7 @@
*/
public static void startup() {
instance = new ContentTypeManager();
- ContentOSGiUtils.getDefault().getExtensionRegistry().addRegistryChangeListener(instance, IContentConstants.RUNTIME_NAME);
+ RegistryFactory.getRegistry().addRegistryChangeListener(instance, IContentConstants.RUNTIME_NAME);
}
/**
@@ -58,7 +57,7 @@
* </p>
*/
public static void shutdown() {
- ContentOSGiUtils.getDefault().getExtensionRegistry().removeRegistryChangeListener(instance);
+ RegistryFactory.getRegistry().removeRegistryChangeListener(instance);
instance = null;
}
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/registry/eclipse/EclipseExtensionRegistry.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/registry/eclipse/EclipseExtensionRegistry.java
index 35467a9..07a5626 100644
--- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/registry/eclipse/EclipseExtensionRegistry.java
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/registry/eclipse/EclipseExtensionRegistry.java
@@ -10,40 +10,41 @@
*******************************************************************************/
package org.eclipse.core.internal.registry.eclipse;
-import java.io.File;
import java.util.Hashtable;
+import org.eclipse.core.internal.registry.ExtensionRegistry;
import org.eclipse.core.internal.runtime.InternalPlatform;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.registry.RegistryFactory;
-import org.eclipse.osgi.service.datalocation.Location;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
/**
* Backward-compatible Eclipse registry implementation.
*/
-public class EclipseExtensionRegistry implements IExtensionRegistry {
- private org.eclipse.equinox.registry.IExtensionRegistry theEquinoxHandle;
- private Object registryKey = new Object();
- ServiceRegistration registrationNew;
+// XXX Eclipse* classes should be renamed to be Legacy or some such
+// XXX EclipseRegistryAdaptor should be renamed to *Converter and the adapt() => convert() or some such
+
+public class EclipseExtensionRegistry implements IExtensionRegistry {
ServiceRegistration registrationOld;
+ // XXX this field name should be updated. Something like "target" or "wrappee" :-)
+ private org.eclipse.equinox.registry.IExtensionRegistry theEquinoxHandle;
public EclipseExtensionRegistry() {
- Location configuration = InternalPlatform.getDefault().getConfigurationLocation();
- File theStorageDir = new File(configuration.getURL().getPath() + '/' + Platform.PI_RUNTIME);
- EclipseRegistryStrategy registryStrategy = new EclipseRegistryStrategy(theStorageDir, configuration.isReadOnly(), registryKey);
- theEquinoxHandle = RegistryFactory.createExtensionRegistry(registryStrategy, registryKey);
+ theEquinoxHandle = RegistryFactory.getRegistry();
+ if (theEquinoxHandle instanceof ExtensionRegistry) {
+ ((ExtensionRegistry) theEquinoxHandle).setCompatibilityStrategy(new EclipseRegistryCompatibility());
+ }
- // Register this registry both under old and new names
+ // XXX Did we used to register the registry as a service? If so, bummer. If not, we should consider
+ // Dropping this. If we do have to register it, there should be a distinguishing property set so
+ // someone can ensure they are getting the legacy registry.
+ // For compatibility, register this registry under old name as well
BundleContext context = InternalPlatform.getDefault().getBundleContext();
- registrationNew = context.registerService(org.eclipse.equinox.registry.IExtensionRegistry.class.getName(), theEquinoxHandle, new Hashtable());
registrationOld = context.registerService(IExtensionRegistry.class.getName(), this, new Hashtable());
}
public void stop() {
- theEquinoxHandle.stop(registryKey);
- registrationNew.unregister();
registrationOld.unregister();
}
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/registry/eclipse/EclipseRegistryStrategy.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/registry/eclipse/EclipseRegistryCompatibility.java
similarity index 82%
rename from bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/registry/eclipse/EclipseRegistryStrategy.java
rename to bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/registry/eclipse/EclipseRegistryCompatibility.java
index 0eb34a1..2f917a4 100644
--- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/registry/eclipse/EclipseRegistryStrategy.java
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/registry/eclipse/EclipseRegistryCompatibility.java
@@ -10,21 +10,15 @@
*******************************************************************************/
package org.eclipse.core.internal.registry.eclipse;
-import java.io.File;
import java.util.EventListener;
import java.util.Map;
import org.eclipse.core.internal.registry.ICompatibilityStrategy;
-import org.eclipse.core.internal.registry.osgi.EquinoxRegistryStrategy;
import org.eclipse.core.runtime.*;
/**
- * The Eclipse registry strategy.
+ * The backward compatibility strategy typing "old" Eclipse and "new" Equinox registry.
*/
-public class EclipseRegistryStrategy extends EquinoxRegistryStrategy implements ICompatibilityStrategy {
-
- public EclipseRegistryStrategy(File theStorageDir, boolean cacheReadOnly, Object key) {
- super(theStorageDir, cacheReadOnly, key);
- }
+public class EclipseRegistryCompatibility implements ICompatibilityStrategy {
/* --- ICompatibilityStrategy - my listeners expect objects in the o.e.c.runtime namespace --- */
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java
index b630ab5..eb8c75d 100644
--- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java
+++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java
@@ -46,12 +46,12 @@
private static final String APPLICATION = "-application"; //$NON-NLS-1$
private static final String[] ARCH_LIST = {Platform.ARCH_PA_RISC, //
- Platform.ARCH_PPC, //
- Platform.ARCH_SPARC, //
- Platform.ARCH_X86, //
- Platform.ARCH_AMD64, //
- Platform.ARCH_IA64, //
- Platform.ARCH_IA64_32};
+ Platform.ARCH_PPC, //
+ Platform.ARCH_SPARC, //
+ Platform.ARCH_X86, //
+ Platform.ARCH_AMD64, //
+ Platform.ARCH_IA64, //
+ Platform.ARCH_IA64_32};
private static final String BOOT = "-boot"; //$NON-NLS-1$
private static final String CLASSLOADER_PROPERTIES = "-classloaderProperties"; //$NON-NLS-1$