geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickmcgu...@apache.org
Subject svn commit: r924890 - /geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-locator/src/main/java/org/apache/geronimo/osgi/locator/ProviderLocator.java
Date Thu, 18 Mar 2010 16:47:27 GMT
Author: rickmcguire
Date: Thu Mar 18 16:47:27 2010
New Revision: 924890

URL: http://svn.apache.org/viewvc?rev=924890&view=rev
Log:
Allow bundle to start if the ProviderRegistry service is not available

Modified:
    geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-locator/src/main/java/org/apache/geronimo/osgi/locator/ProviderLocator.java

Modified: geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-locator/src/main/java/org/apache/geronimo/osgi/locator/ProviderLocator.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-locator/src/main/java/org/apache/geronimo/osgi/locator/ProviderLocator.java?rev=924890&r1=924889&r2=924890&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-locator/src/main/java/org/apache/geronimo/osgi/locator/ProviderLocator.java
(original)
+++ geronimo/specs/trunk/geronimo-osgi-support/geronimo-osgi-locator/src/main/java/org/apache/geronimo/osgi/locator/ProviderLocator.java
Thu Mar 18 16:47:27 2010
@@ -56,10 +56,19 @@ public class ProviderLocator {
      * @param c      The starup BundleContext.
      */
     public static void init(BundleContext c) {
-        context = c;
-        // just create a tracker for our lookup service
-        registryTracker = new ServiceTracker(context, ProviderRegistry.class.getName(), null);
-        ((ServiceTracker)registryTracker).open();
+        try {
+            // just create a tracker for our lookup service
+            // NB:  We use the hard coded name in case the registry service has not
+            // been started first.  Once this does get started, then everything should
+            // resolved.
+            registryTracker = new ServiceTracker(context, "org.apache.geronimo.osgi.registry.api.ProviderRegistry",
null);
+            ((ServiceTracker)registryTracker).open();
+            // do this last...it helps indicate if we have an initialized registry.
+            context = c;
+        } catch (Throwable e) {
+            // if there were any errors, then the registry is not available.
+            registryTracker = null;
+        }
     }
 
 
@@ -67,9 +76,11 @@ public class ProviderLocator {
      * Cleanup resources on bundle shutdown.
      */
     public static void destroy() {
-        // shutdown our tracking of the provider registry.
-        ((ServiceTracker)registryTracker).close();
-        registryTracker = null;
+        if (registryTracker != null) {
+            // shutdown our tracking of the provider registry.
+            ((ServiceTracker)registryTracker).close();
+            registryTracker = null;
+        }
     }
 
 



Mime
View raw message