You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by dj...@apache.org on 2013/05/07 23:50:23 UTC

svn commit: r1480106 - in /felix/trunk/scr/src/main/java/org/apache/felix/scr/impl: config/ConfigurationSupport.java manager/ImmediateComponentManager.java

Author: djencks
Date: Tue May  7 21:50:23 2013
New Revision: 1480106

URL: http://svn.apache.org/r1480106
Log:
FELIX-3651 deal with weaker/stronger pid bindings

Modified:
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurationSupport.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ImmediateComponentManager.java

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurationSupport.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurationSupport.java?rev=1480106&r1=1480105&r2=1480106&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurationSupport.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurationSupport.java Tue May  7 21:50:23 2013
@@ -243,14 +243,13 @@ public class ConfigurationSupport implem
             {
                 switch (event.getType()) {
                 case ConfigurationEvent.CM_DELETED:
-                    //TODO fall back to less-strong pid match
                     componentHolder.configurationDeleted(pid.getServicePid());
+                    //fall back to less-strong pid match
+                    configureComponentHolder( componentHolder );
                     break;
 
                 case ConfigurationEvent.CM_UPDATED:
                 {
-                    //TODO what if this is a new config with a stronger (or weaker) binding than 
-                    // an existing matching config?
                     final BundleComponentActivator activator = componentHolder.getActivator();
                     if (activator == null)
                     {
@@ -263,13 +262,23 @@ public class ConfigurationSupport implem
                         break;
                     }
 
-                    final Configuration config = getConfiguration( pid, componentHolder, bundleContext );
-                    if ( checkBundleLocation( config, bundleContext.getBundle() ) )
+                    TargetedPID targetedPid = factoryPid == null? pid: factoryPid;
+                    TargetedPID oldTargetedPID = componentHolder.getConfigurationTargetedPID();
+                    if ( targetedPid.equals(oldTargetedPID) || targetedPid.bindsStronger( oldTargetedPID ))
                     {
-                        long changeCount = changeCounter.getChangeCount( config, true, componentHolder.getChangeCount( pid.getServicePid() ) );
-                        componentHolder.configurationUpdated( pid.getServicePid(), config.getProperties(), changeCount, factoryPid == null? pid: factoryPid );
+                        final Configuration config = getConfiguration( pid, componentHolder, bundleContext );
+                        if ( checkBundleLocation( config, bundleContext.getBundle() ) )
+                        {
+                            //If this is replacing a weaker targetedPID delete the old one.
+                            if ( !targetedPid.equals(oldTargetedPID) && oldTargetedPID != null)
+                            {
+                                componentHolder.configurationDeleted( pid.getServicePid() );
+                            }
+                            long changeCount = changeCounter.getChangeCount( config, true, componentHolder.getChangeCount( pid.getServicePid() ) );
+                            componentHolder.configurationUpdated( pid.getServicePid(), config.getProperties(), changeCount, targetedPid );
+                        }
                     }
-                    
+
                     break;
                 }
                 case ConfigurationEvent.CM_LOCATION_CHANGED:
@@ -287,8 +296,9 @@ public class ConfigurationSupport implem
                         break;
                     }
 
+                    TargetedPID targetedPid = factoryPid == null? pid: factoryPid;
                     TargetedPID oldTargetedPID = componentHolder.getConfigurationTargetedPID();
-                    if ( pid.equals(oldTargetedPID))
+                    if ( targetedPid.equals(oldTargetedPID))
                     {
                         //this sets the location to this component's bundle if not already set.  OK here
                         //since it used to be set to this bundle, ok to reset it
@@ -305,7 +315,7 @@ public class ConfigurationSupport implem
                         //else still matches
                         break;
                     }
-                    boolean better = pid.bindsStronger( oldTargetedPID );
+                    boolean better = targetedPid.bindsStronger( oldTargetedPID );
                     if ( better )
                     {
                         //this sets the location to this component's bundle if not already set.  OK here

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ImmediateComponentManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ImmediateComponentManager.java?rev=1480106&r1=1480105&r2=1480106&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ImmediateComponentManager.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ImmediateComponentManager.java Tue May  7 21:50:23 2013
@@ -546,7 +546,7 @@ public class ImmediateComponentManager<S
 
         // unsatisfied component and non-ignored configuration may change targets
         // to satisfy references
-        if ( getState() == STATE_UNSATISFIED && configuration != null
+        if ( getState() == STATE_UNSATISFIED
                 && !getComponentMetadata().isConfigurationIgnored() )
         {
             log( LogService.LOG_DEBUG, "Attempting to activate unsatisfied component", null );