FELIX-3651 components using factory pids can't fall back on less specific targeted pids when a configuration is deleted

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1522045 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurationSupport.java b/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurationSupport.java
index 93725c7..71a23b6 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurationSupport.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurationSupport.java
@@ -132,6 +132,8 @@
                                 boolean created = false;
                                 for (Configuration config: factory)
                                 {
+                                    Activator.log( LogService.LOG_DEBUG, null, "Configuring holder {0} with factory configuration {1}",
+                                            new Object[] {holder, config}, null );
                                     config = getConfiguration( ca, config.getPid() );
                                     if ( checkBundleLocation( config, bundleContext.getBundle() ))
                                     {
@@ -148,6 +150,8 @@
                                 if (singleton != null)
                                 {
                                     singleton = getConfiguration( ca, singleton.getPid() );
+                                    Activator.log( LogService.LOG_DEBUG, null, "Configuring holder {0} with configuration {1}",
+                                            new Object[] {holder, singleton}, null );
                                     if ( singleton != null && checkBundleLocation( singleton, bundleContext.getBundle() ))
                                     {
                                         long changeCount = changeCounter.getChangeCount( singleton, false, -1 );
@@ -251,7 +255,7 @@
             {
                 switch (event.getType()) {
                 case ConfigurationEvent.CM_DELETED:
-                    if ( !configureComponentHolder( componentHolder ) )
+                    if ( factoryPid != null || !configureComponentHolder( componentHolder ) )
                     {
                         componentHolder.configurationDeleted( pid.getServicePid() );
                     }
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/config/ImmediateComponentHolder.java b/scr/src/main/java/org/apache/felix/scr/impl/config/ImmediateComponentHolder.java
index 89dc367..0fbf4b2 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/config/ImmediateComponentHolder.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/config/ImmediateComponentHolder.java
@@ -497,7 +497,7 @@
 
         ImmediateComponentHolder other = (ImmediateComponentHolder) object;
         return m_activator == other.m_activator
-                && getComponentMetadata().getName().equals(other.getComponentMetadata().getName());
+                && getName().equals(other.getName());
     }
     
    /**
@@ -505,14 +505,26 @@
     * 
     * @return An integer which is a hash code value for this object.
     */
+   @Override
    public int hashCode()
    {
-       return getComponentMetadata().getName().hashCode();
+       return getName().hashCode();
+   }
+   
+   @Override
+   public String toString()
+   {
+       return "[ImmediateComponentHolder:" + getName() + "]";
+   }
+   
+   String getName()
+   {
+       return m_componentMetadata.getName();
    }
 
     //---------- internal
 
-   /**
+    /**
      * Returns all components from the map, optionally also removing them
      * from the map. If there are no components in the map, <code>null</code>
      * is returned.