You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by da...@apache.org on 2015/02/11 12:36:34 UTC

svn commit: r1658933 - in /felix/trunk/scr/src: main/java/org/apache/felix/scr/impl/config/ConfigurableComponentHolder.java test/java/org/apache/felix/scr/integration/ComponentFactoryTest.java test/resources/integration_test_simple_factory_components.xml

Author: davidb
Date: Wed Feb 11 11:36:34 2015
New Revision: 1658933

URL: http://svn.apache.org/r1658933
Log:
FELIX-4793 Components with an empty configuration are created even if configuration is required or available

This happens when the 'Obsolete Factory Component Factory' is set to true.
This commit addresses, the issue. Thanks to Carsten Ziegeler for the code fix.
A test is also included.


Modified:
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurableComponentHolder.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentFactoryTest.java
    felix/trunk/scr/src/test/resources/integration_test_simple_factory_components.xml

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurableComponentHolder.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurableComponentHolder.java?rev=1658933&r1=1658932&r2=1658933&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurableComponentHolder.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurableComponentHolder.java Wed Feb 11 11:36:34 2015
@@ -644,7 +644,8 @@ public class ConfigurableComponentHolder
             {
                 if ( isSatisfied() )
                 {
-                    if ( m_factoryPidIndex == null || m_componentMetadata.isObsoleteFactoryComponentFactory())
+                    if ( m_factoryPidIndex == null ||
+                            (m_componentMetadata.isObsoleteFactoryComponentFactory() && !m_componentMetadata.isConfigurationRequired()))
                     {
                         m_singleComponent = createComponentManager(false);
                         cms.add( m_singleComponent );

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentFactoryTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentFactoryTest.java?rev=1658933&r1=1658932&r2=1658933&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentFactoryTest.java (original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentFactoryTest.java Wed Feb 11 11:36:34 2015
@@ -143,6 +143,19 @@ public class ComponentFactoryTest extend
     }
 
     @Test
+    public void test_component_factory_require_configuration_obsolete() throws Exception
+    {
+        final String componentname = "factory.component.configuration.obsolete";
+
+        TestCase.assertNull(SimpleComponent.INSTANCE);
+
+        createFactoryConfiguration(componentname);
+        delay();
+        getConfigurationsDisabledThenEnable(componentname, 1, ComponentConfigurationDTO.ACTIVE);
+        TestCase.assertEquals(PROP_NAME, SimpleComponent.INSTANCE.getProperty(PROP_NAME));
+    }
+
+    @Test
     public void test_component_factory_optional_configuration() throws Exception
     {
         final String componentname = "factory.component.configuration.optional";

Modified: felix/trunk/scr/src/test/resources/integration_test_simple_factory_components.xml
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/resources/integration_test_simple_factory_components.xml?rev=1658933&r1=1658932&r2=1658933&view=diff
==============================================================================
--- felix/trunk/scr/src/test/resources/integration_test_simple_factory_components.xml (original)
+++ felix/trunk/scr/src/test/resources/integration_test_simple_factory_components.xml Wed Feb 11 11:36:34 2015
@@ -36,6 +36,15 @@
         <implementation class="org.apache.felix.scr.integration.components.SimpleComponent" />
     </scr:component>
     
+    <scr:component name="factory.component.configuration.obsolete"
+        enabled="false"
+        configuration-policy="require"
+        xmlns:felix="http://felix.apache.org/xmlns/scr/extensions/v1.0.0"
+        felix:obsoleteFactoryComponentFactory="true" >
+        <implementation class="org.apache.felix.scr.integration.components.SimpleComponent" />
+        <property name="foo">bar</property>
+    </scr:component>
+
     <scr:component name="factory.component.configuration.optional"
         enabled="false"
         configuration-policy="optional"