FELIX-1922 Always mimick existing configuration to component factory instances. In case of Configuration Admin service not providing configuration, an empty configuration is placed to simulate existence. Reason for this is that component factories do not obey configuration-policy=require for satisfaction setting.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@890259 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentFactoryImpl.java b/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentFactoryImpl.java
index db888b6..a6b80b3 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentFactoryImpl.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentFactoryImpl.java
@@ -93,6 +93,7 @@
         super( activator, metadata );
         m_componentInstances = new IdentityHashMap();
         m_isConfigurationFactory = activator.getConfiguration().isFactoryEnabled();
+        m_configuration = new Hashtable();
     }
 
 
@@ -178,7 +179,7 @@
 
     public boolean hasConfiguration()
     {
-        return true;
+        return m_configuration != null;
     }
 
 
@@ -224,19 +225,28 @@
     {
         if ( pid.equals( getComponentMetadata().getName() ) )
         {
-            m_configuration = null;
-            reconfigureComponents( null );
+            // deleting configuration of a component factory is like
+            // providing an empty configuration
+            m_configuration = new Hashtable();
         }
-        else if ( m_isConfigurationFactory && m_configuredServices != null )
+        else if ( m_isConfigurationFactory )
         {
-            ImmediateComponentManager cm = ( ImmediateComponentManager ) m_configuredServices.remove( pid );
-            if ( cm != null )
+            if ( m_configuredServices != null )
             {
-                log( LogService.LOG_DEBUG, "Disposing component after configuration deletion", null );
+                ImmediateComponentManager cm = ( ImmediateComponentManager ) m_configuredServices.remove( pid );
+                if ( cm != null )
+                {
+                    log( LogService.LOG_DEBUG, "Disposing component after configuration deletion", null );
 
-                cm.dispose();
+                    cm.dispose();
+                }
             }
         }
+        else
+        {
+            // 112.7 Factory Configuration not allowed for factory component
+            log( LogService.LOG_ERROR, "Component Factory cannot be configured by factory configuration", null );
+        }
     }
 
 
@@ -245,7 +255,6 @@
         if ( pid.equals( getComponentMetadata().getName() ) )
         {
             m_configuration = configuration;
-            reconfigureComponents( configuration );
         }
         else if ( m_isConfigurationFactory )
         {
@@ -304,28 +313,6 @@
 
 
     /**
-     * Reconfigure all components created calling the
-     * {@link #newInstance(Dictionary)} method to update them with the new
-     * configuration from the configuration admin.
-     * <p>
-     * This method is not used to reconfigure components created as part of
-     * backwards compatible support for configuration factories since they
-     * are reconfigured directly by {@link #configurationUpdated(String, Dictionary)}
-     * and {@link #configurationDeleted(String)}
-     *
-     * @param configuration the new configuration
-     */
-    private void reconfigureComponents( Dictionary configuration )
-    {
-        ImmediateComponentManager[] cms = getComponentManagers( m_componentInstances );
-        for ( int i = 0; i < cms.length; i++ )
-        {
-            cms[i].reconfigure( configuration );
-        }
-    }
-
-
-    /**
      * A component factory component holder disables the held components by
      * disabling itself.
      */