felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r1067309 - /felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java
Date Fri, 04 Feb 2011 22:05:40 GMT
Author: fmeschbe
Date: Fri Feb  4 22:05:40 2011
New Revision: 1067309

URL: http://svn.apache.org/viewvc?rev=1067309&view=rev
Log:
FELIX-2824 Besides setting the configuration support object up
when the Configuration Admin service is registered after starting
Declarative Services the support should also be setup if the
Configuration Admin service is already available before Declarative
Services is started

Modified:
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java?rev=1067309&r1=1067308&r2=1067309&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java Fri Feb
 4 22:05:40 2011
@@ -113,13 +113,20 @@ public class ComponentRegistry implement
         // keep me informed on ConfigurationAdmin state changes
         try
         {
-            context.addServiceListener( this, "(objectclass=" + CONFIGURATION_ADMIN + ")"
);
+            context.addServiceListener(this, "(objectclass=" + CONFIGURATION_ADMIN + ")");
         }
-        catch ( InvalidSyntaxException ise )
+        catch (InvalidSyntaxException ise)
         {
             // not expected (filter is tested valid)
         }
 
+        // If the Configuration Admin Service is already registered, setup
+        // configuration support immediately
+        if (context.getServiceReference(CONFIGURATION_ADMIN) != null)
+        {
+            getOrCreateConfigurationSupport();
+        }
+
         // register as ScrService
         Dictionary props = new Hashtable();
         props.put( Constants.SERVICE_DESCRIPTION, "Declarative Services Management Agent"
);
@@ -448,7 +455,7 @@ public class ComponentRegistry implement
     {
         if (event.getType() == ServiceEvent.REGISTERED)
         {
-            this.configurationSupport = new ConfigurationSupport(this.m_bundleContext, this);
+            ConfigurationSupport configurationSupport = getOrCreateConfigurationSupport();
 
             final ServiceReference caRef = event.getServiceReference();
             final Object service = m_bundleContext.getService(caRef);
@@ -456,7 +463,7 @@ public class ComponentRegistry implement
             {
                 try
                 {
-                    this.configurationSupport.configureComponentHolders(caRef, service);
+                    configurationSupport.configureComponentHolders(caRef, service);
                 }
                 finally
                 {
@@ -466,11 +473,7 @@ public class ComponentRegistry implement
         }
         else if (event.getType() == ServiceEvent.UNREGISTERING)
         {
-            if (configurationSupport != null)
-            {
-                this.configurationSupport.dispose();
-                this.configurationSupport = null;
-            }
+            disposeConfigurationSupport();
         }
     }
 
@@ -517,4 +520,22 @@ public class ComponentRegistry implement
         // fall back: bundle is not considered active
         return false;
     }
+
+    private ConfigurationSupport getOrCreateConfigurationSupport()
+    {
+        if (configurationSupport == null)
+        {
+            configurationSupport = new ConfigurationSupport(m_bundleContext, this);
+        }
+        return configurationSupport;
+    }
+
+    private void disposeConfigurationSupport()
+    {
+        if (configurationSupport != null)
+        {
+            this.configurationSupport.dispose();
+            this.configurationSupport = null;
+        }
+    }
 }



Mime
View raw message