felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1591423 - in /felix/trunk/scr/src: main/java/org/apache/felix/scr/impl/manager/ main/java/org/apache/felix/scr/impl/metadata/ test/java/org/apache/felix/scr/integration/ test/resources/
Date Wed, 30 Apr 2014 18:01:44 GMT
Author: djencks
Date: Wed Apr 30 18:01:44 2014
New Revision: 1591423

URL: http://svn.apache.org/r1591423
Log:
[FELIX-4022] Implement spec compliant behavior for pre and post 1.3 with a flag to get reasonable
behavior pre-1.3.  Question is whether deleting a config calls modify(1.3) or deactivates(pre
1.3)

Modified:
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/SingleComponentManager.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/ComponentMetadata.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentConfigurationTest.java
    felix/trunk/scr/src/test/resources/integration_test_simple_components.xml

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/SingleComponentManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/SingleComponentManager.java?rev=1591423&r1=1591422&r2=1591423&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/SingleComponentManager.java
(original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/SingleComponentManager.java
Wed Apr 30 18:01:44 2014
@@ -667,6 +667,12 @@ public class SingleComponentManager<S> e
 
     private boolean modify()
     {
+    	//0 SCR 112.7.1 If configuration is deleted, and version is < 1.3 and no flag set,
then deactivate unconditionally.
+    	// For version 1.3 and later, or with a flag, more sensible behavior is allowed.
+    	if ( m_configurationProperties == null && !getComponentMetadata().isDeleteCallsModify()){
+    		return false;
+    	}
+    	
         // 1. no live update if there is no declared method
         if ( getComponentMetadata().getModified() == null )
         {

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/ComponentMetadata.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/ComponentMetadata.java?rev=1591423&r1=1591422&r2=1591423&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/ComponentMetadata.java
(original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/metadata/ComponentMetadata.java
Wed Apr 30 18:01:44 2014
@@ -463,6 +463,16 @@ public class ComponentMetadata
     {
         return getNamespaceCode() >= XmlHandler.DS_VERSION_1_2_FELIX;
     }
+    
+    /**
+     * Returns <code>true</code> if the metadata declaration has used the
+     * Declarative Services version 1.3 namespace or a later namespace.
+     */
+    public boolean isDS13()
+    {
+        return getNamespaceCode() >= XmlHandler.DS_VERSION_1_3;
+    }
+    
 
 
     /**

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentConfigurationTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentConfigurationTest.java?rev=1591423&r1=1591422&r2=1591423&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentConfigurationTest.java
(original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ComponentConfigurationTest.java
Wed Apr 30 18:01:44 2014
@@ -183,7 +183,29 @@ public class ComponentConfigurationTest 
     public void test_SimpleComponent_dynamic_configuration()
     {
         final String pid = "DynamicConfigurationComponent";
-        final Component component = findComponentByName( pid );
+        boolean pre13 = true;
+        dynamicConfigTest(pid, pre13);
+    }
+
+    @Test
+    public void test_SimpleComponent_dynamic_configuration_13()
+    {
+        final String pid = "DynamicConfigurationComponent13";
+        boolean pre13 = false;
+        dynamicConfigTest(pid, pre13);
+    }
+    
+    @Test
+    public void test_SimpleComponent_dynamic_configuration_flag()
+    {
+        final String pid = "DynamicConfigurationComponentFlag";
+        boolean pre13 = false;
+        dynamicConfigTest(pid, pre13);
+    }
+
+
+	private void dynamicConfigTest(final String pid, boolean pre13) {
+		final Component component = findComponentByName( pid );
 
         deleteConfig( pid );
         delay();
@@ -216,7 +238,14 @@ public class ComponentConfigurationTest 
         delay();
 
         TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
-        TestCase.assertSame( instance, SimpleComponent.INSTANCE );
+        if (pre13)
+        {
+            TestCase.assertNotSame( instance, SimpleComponent.INSTANCE );
+        }
+        else
+        {
+            TestCase.assertSame( instance, SimpleComponent.INSTANCE );
+        }
         TestCase.assertNull( SimpleComponent.INSTANCE.getProperty( PROP_NAME ) );
         TestCase.assertEquals( pid, SimpleComponent.INSTANCE.getProperty( Constants.SERVICE_PID
) );
 
@@ -225,7 +254,7 @@ public class ComponentConfigurationTest 
 
         TestCase.assertEquals( Component.STATE_DISABLED, component.getState() );
         TestCase.assertNull( SimpleComponent.INSTANCE );
-    }
+	}
 
 
     @Test
@@ -486,7 +515,7 @@ public class ComponentConfigurationTest 
 
             // optional ref missing --> component active
             TestCase.assertEquals( Component.STATE_ACTIVE, component.getState() );
-            TestCase.assertEquals( instance, SimpleComponent.INSTANCE );
+            TestCase.assertNotSame( instance, SimpleComponent.INSTANCE );
             TestCase.assertNull( SimpleComponent.INSTANCE.m_singleRef );
 
             component.disable();

Modified: felix/trunk/scr/src/test/resources/integration_test_simple_components.xml
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/resources/integration_test_simple_components.xml?rev=1591423&r1=1591422&r2=1591423&view=diff
==============================================================================
--- felix/trunk/scr/src/test/resources/integration_test_simple_components.xml (original)
+++ felix/trunk/scr/src/test/resources/integration_test_simple_components.xml Wed Apr 30 18:01:44
2014
@@ -50,6 +50,19 @@
         <property name="service.pid" value="DynamicConfigurationComponent" />
     </scr:component>
 
+    <scr13:component xmlns:scr13="http://www.osgi.org/xmlns/scr/v1.3.0" name="DynamicConfigurationComponent13"
+        enabled="false" modified="configure">
+        <implementation class="org.apache.felix.scr.integration.components.SimpleComponent"
/>
+        <property name="service.pid" value="DynamicConfigurationComponent13" />
+    </scr13:component>
+
+    <scr:component xmlns:felix="http://felix.apache.org/xmlns/scr/extensions/v1.0.0" name="DynamicConfigurationComponentFlag"
+        enabled="false" modified="configure"
+        felix:deleteCallsModify="true">
+        <implementation class="org.apache.felix.scr.integration.components.SimpleComponent"
/>
+        <property name="service.pid" value="DynamicConfigurationComponentFlag" />
+    </scr:component>
+
     <!-- component dynamically updates configuration with a required reference plus target-->
     <scr:component name="DynamicConfigurationComponentWithRequiredReference"
         enabled="false" modified="configure">



Mime
View raw message