You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2017/02/17 06:38:17 UTC

svn commit: r1783333 - /felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ConfigAdminTracker.java

Author: cziegeler
Date: Fri Feb 17 06:38:17 2017
New Revision: 1783333

URL: http://svn.apache.org/viewvc?rev=1783333&view=rev
Log:
FELIX-5507 : ConfigurationAdmin might not be visible to SCR implementation

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

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ConfigAdminTracker.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ConfigAdminTracker.java?rev=1783333&r1=1783332&r2=1783333&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ConfigAdminTracker.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/helper/ConfigAdminTracker.java Fri Feb 17 06:38:17 2017
@@ -22,6 +22,7 @@ import org.apache.felix.scr.impl.manager
 import org.apache.felix.scr.impl.manager.RegionConfigurationSupport;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.cm.ConfigurationAdmin;
+import org.osgi.service.log.LogService;
 import org.osgi.util.tracker.ServiceTracker;
 import org.osgi.util.tracker.ServiceTrackerCustomizer;
 
@@ -41,16 +42,42 @@ public class ConfigAdminTracker
             new ServiceTrackerCustomizer<ConfigurationAdmin, RegionConfigurationSupport>()
             {
 
+                @Override
                 public RegionConfigurationSupport addingService(ServiceReference<ConfigurationAdmin> reference)
                 {
+                    // let's do a quick check if the returned CA service is using the same
+                    // CA API as is visible to this (SCR) bundle
+                    boolean visible = false;
+                    try
+                    {
+                        ConfigurationAdmin ca = componentActivator.getBundleContext().getService(reference);
+                        if ( ca != null )
+                        {
+                            visible = true;
+                            componentActivator.getBundleContext().ungetService(reference);
+                        }
+                    }
+                    catch ( final Exception ex)
+                    {
+                        componentActivator.log(LogService.LOG_ERROR,
+                                "Configuration admin API visible to bundle " + componentActivator.getBundleContext().getBundle() +
+                                " is not the same as the Configuration Admin API visible to the SCR implementation.", null, null, ex);
+                    }
+
+                    if ( !visible )
+                    {
+                        return null;
+                    }
                     return componentActivator.setRegionConfigurationSupport( reference );
                 }
 
+                @Override
                 public void modifiedService(ServiceReference<ConfigurationAdmin> reference,
                     RegionConfigurationSupport service)
                 {
                 }
 
+                @Override
                 public void removedService(ServiceReference<ConfigurationAdmin> reference,
                     RegionConfigurationSupport rcs)
                 {