Bug 117154 uniform API for obtaining the 'default' extension registry
diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/RuntimeLog.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/RuntimeLog.java
index 0d7be58..d0bd2a3 100644
--- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/RuntimeLog.java
+++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/RuntimeLog.java
@@ -15,10 +15,11 @@
 import org.eclipse.core.runtime.*;
 
 /**
- * This log infrastructure was split from the InternalPlatform.
+ * NOT API!!!  This log infrastructure was split from the InternalPlatform.
  * 
  * @since org.eclipse.equinox.common 1.0
  */
+// XXX this must be removed and replaced with something more reasonable
 public final class RuntimeLog {
 
 	private static ArrayList logListeners = new ArrayList(5);
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryMessages.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryMessages.java
index e245e6f..abb9172 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryMessages.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/RegistryMessages.java
@@ -19,6 +19,9 @@
 	public static final String OWNER_NAME = "org.eclipse.equinox.registry"; //$NON-NLS-1$
 
 	private static final String BUNDLE_NAME = "org.eclipse.core.internal.registry.messages"; //$NON-NLS-1$
+	
+	// Bundle
+	public static String bundle_not_activated;	
 
 	// Extension Registry
 	public static String meta_registryCacheWriteProblems;
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/messages.properties b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/messages.properties
index 9acabd8..7661bed 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/messages.properties
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/messages.properties
@@ -10,6 +10,9 @@
 ###############################################################################
 ### Extension registry messages
 
+### Bundle
+bundle_not_activated = The bundle org.eclipse.quinox.registry was not activated.
+
 ### Extension Registry
 meta_registryCacheWriteProblems = Trouble writing to the registry cache file.
 meta_registryCacheReadProblems = Trouble reading from the registry cache file.
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/OSGIUtils.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/OSGIUtils.java
index b967371..d1af544 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/OSGIUtils.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/OSGIUtils.java
@@ -10,7 +10,10 @@
  *******************************************************************************/
 package org.eclipse.core.internal.registry.osgi;
 
-import java.util.Date;
+import org.eclipse.core.internal.registry.RegistryMessages;
+import org.eclipse.core.internal.runtime.RuntimeLog;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
 import org.eclipse.osgi.service.datalocation.Location;
 import org.eclipse.osgi.service.debug.DebugOptions;
 import org.eclipse.osgi.service.resolver.PlatformAdmin;
@@ -27,8 +30,7 @@
 public class OSGIUtils {
 	private ServiceTracker debugTracker = null;
 	private ServiceTracker bundleTracker = null;
-	// XXX platfromTracker is misspelt.
-	private ServiceTracker platfromTracker = null;
+	private ServiceTracker platformTracker = null;
 	private ServiceTracker configurationLocationTracker = null;
 
 	// OSGI system properties.  Copied from EclipseStarter
@@ -49,26 +51,10 @@
 		initServices();
 	}
 
-	/**
-	 * Print a debug message to the console. 
-	 * Pre-pend the message with the current date and the name of the current thread.
-	 */
-	// XXX be careful using this method.  In general you should try to log first and then if 
-	//  debug is on print to system out.  
-	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("Registry OSGIUtils called before plugin started"); //$NON-NLS-1$
+			RuntimeLog.log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, 0, RegistryMessages.bundle_not_activated, null));
 			return;
 		}
 
@@ -78,8 +64,8 @@
 		bundleTracker = new ServiceTracker(context, PackageAdmin.class.getName(), null);
 		bundleTracker.open();
 
-		platfromTracker = new ServiceTracker(context, PlatformAdmin.class.getName(), null);
-		platfromTracker.open();
+		platformTracker = new ServiceTracker(context, PlatformAdmin.class.getName(), null);
+		platformTracker.open();
 
 		// locations
 
@@ -108,15 +94,15 @@
 			configurationLocationTracker.close();
 			configurationLocationTracker = null;
 		}
-		if (platfromTracker != null) {
-			platfromTracker.close();
-			platfromTracker = null;
+		if (platformTracker != null) {
+			platformTracker.close();
+			platformTracker = null;
 		}
 	}
 
 	public boolean getBooleanDebugOption(String option, boolean defaultValue) {
 		if (debugTracker == null) {
-			message("Debug tracker is not set"); //$NON-NLS-1$
+			RuntimeLog.log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, 0, RegistryMessages.bundle_not_activated, null));
 			return defaultValue;
 		}
 		DebugOptions options = (DebugOptions) debugTracker.getService();
@@ -130,7 +116,7 @@
 
 	public PackageAdmin getPackageAdmin() {
 		if (bundleTracker == null) {
-			message("Bundle tracker is not set"); //$NON-NLS-1$
+			RuntimeLog.log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, 0, RegistryMessages.bundle_not_activated, null));
 			return null;
 		}
 		return (PackageAdmin) bundleTracker.getService();
@@ -181,10 +167,9 @@
 	}
 
 	public PlatformAdmin getPlatformAdmin() {
-		if (platfromTracker != null)
-			return (PlatformAdmin) platfromTracker.getService();
-		else
+		if (platformTracker == null)
 			return null;
+		return (PlatformAdmin) platformTracker.getService();
 	}
 
 }
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/RegistryProviderOSGI.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/RegistryProviderOSGI.java
index 08fd658..a5b7288 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/RegistryProviderOSGI.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/RegistryProviderOSGI.java
@@ -10,6 +10,10 @@
  *******************************************************************************/
 package org.eclipse.core.internal.registry.osgi;
 
+import org.eclipse.core.internal.registry.RegistryMessages;
+import org.eclipse.core.internal.runtime.RuntimeLog;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
 import org.eclipse.equinox.registry.IExtensionRegistry;
 import org.eclipse.equinox.registry.IRegistryProvider;
 import org.osgi.framework.BundleContext;
@@ -26,8 +30,7 @@
 		if (registryTracker == null) {
 			BundleContext context = Activator.getContext();
 			if (context == null) {
-			// XXX should not print to system out.  Have to at least try and log.
-				OSGIUtils.message(this.getClass().getName() + ": plugin context is not set"); //$NON-NLS-1$
+				RuntimeLog.log(new Status(IStatus.ERROR, RegistryMessages.OWNER_NAME, 0, RegistryMessages.bundle_not_activated, null));
 				return null;
 			}
 			registryTracker = new ServiceTracker(context, IExtensionRegistry.class.getName(), null);
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/RegistryStrategyOSGI.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/RegistryStrategyOSGI.java
index 580b9f0..4588594 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/RegistryStrategyOSGI.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/osgi/RegistryStrategyOSGI.java
@@ -41,12 +41,8 @@
  *  - Performs registry validation based on the time stamps of the plugin.xml / fragment.xml files
  *  - XML parser is obtained via an OSGi service
  *  
- * XXX really?!!
- *  Only one registry with OSGI strategy can be instantied in the running application.
- *  @see RegistryFactory#setRegistryProvider(IRegistryProvider)
- *  
+ * @see RegistryFactory#setRegistryProvider(IRegistryProvider)
  * @since org.eclipse.equinox.registry 1.0
- * 
  */
 
 public class RegistryStrategyOSGI extends RegistryStrategy {
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/equinox/registry/RegistryFactory.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/equinox/registry/RegistryFactory.java
index ecc0f90..2fa7c0c 100644
--- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/equinox/registry/RegistryFactory.java
+++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/equinox/registry/RegistryFactory.java
@@ -47,12 +47,10 @@
 	 * 
 	 * @return existing extension registry or null
 	 */
-	// XXX the team style is to put test filters first then do the work.  So here the if would
-	//   be == null then return null.  Then the return of getRegistry().
 	public static IExtensionRegistry getRegistry() {
-		if (defaultRegistryProvider != null)
-			return defaultRegistryProvider.getRegistry();
-		return null;
+		if (defaultRegistryProvider == null)
+			return null;
+		return defaultRegistryProvider.getRegistry();
 	}
 
 	/**