felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1602648 - in /felix/trunk/scr/src: main/java/org/apache/felix/scr/impl/config/ main/java/org/apache/felix/scr/impl/manager/ test/java/org/apache/felix/scr/impl/config/ test/java/org/apache/felix/scr/integration/ test/resources/
Date Sun, 15 Jun 2014 01:10:26 GMT
Author: djencks
Date: Sun Jun 15 01:10:25 2014
New Revision: 1602648

URL: http://svn.apache.org/r1602648
Log:
FELIX-4402 reimplement how obsolete configurable component factory works

Removed:
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/ConfigurationComponentFactoryImpl.java
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/impl/config/ConfiguredComponentHolderTest.java
    felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ConfigurationComponentFactoryTest.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=1602648&r1=1602647&r2=1602648&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
Sun Jun 15 01:10:25 2014
@@ -36,7 +36,6 @@ import org.apache.felix.scr.impl.helper.
 import org.apache.felix.scr.impl.helper.SimpleLogger;
 import org.apache.felix.scr.impl.manager.AbstractComponentManager;
 import org.apache.felix.scr.impl.manager.ComponentFactoryImpl;
-import org.apache.felix.scr.impl.manager.ConfigurationComponentFactoryImpl;
 import org.apache.felix.scr.impl.manager.SingleComponentManager;
 import org.apache.felix.scr.impl.manager.ServiceFactoryComponentManager;
 import org.apache.felix.scr.impl.metadata.ComponentMetadata;
@@ -155,19 +154,20 @@ public class ConfigurableComponentHolder
         this.m_enabled = false;
     }
 
-    protected AbstractComponentManager<S> createComponentManager()
+    protected AbstractComponentManager<S> createComponentManager(boolean factoryConfiguration)
     {
 
         AbstractComponentManager<S> manager;
         if ( m_componentMetadata.isFactory() )
         {
-            if ( !m_componentMetadata.isObsoleteFactoryComponentFactory() )
+            //TODO is there any check to make sure factory component factories are enabled
before creating them?
+            if ( !m_componentMetadata.isObsoleteFactoryComponentFactory() || !factoryConfiguration
)
             {
                 manager = new ComponentFactoryImpl<S>(this );
             }
             else
             {
-                manager = new ConfigurationComponentFactoryImpl<S>(this );
+                manager = new SingleComponentManager<S>(this, m_componentMethods, true
);
             }
         }
         else if ( m_componentMetadata.getServiceScope() == Scope.bundle )
@@ -351,7 +351,7 @@ public class ConfigurableComponentHolder
                 m_factoryTargetedPids.put(pid.getServicePid(), factoryPid);
                 m_factoryChangeCount.put(pid.getServicePid(), changeCount);
                 if (m_enabled && isSatisfied()) {
-                    if (m_singleComponent != null) {
+                    if (m_singleComponent != null && !m_componentMetadata.isObsoleteFactoryComponentFactory())
{
                         AbstractComponentManager<S> scm = m_singleComponent;
                         scms.put( scm, mergeProperties( pid.getServicePid() ) );
                         m_singleComponent = null;
@@ -359,7 +359,7 @@ public class ConfigurableComponentHolder
                     } else if (m_components.containsKey(pid.getServicePid())) {
                         scms.put( m_components.get(pid.getServicePid()), mergeProperties(
pid.getServicePid())  );
                     } else {
-                        AbstractComponentManager<S> scm = createComponentManager();
+                        AbstractComponentManager<S> scm = createComponentManager(true);
                         m_components.put(pid.getServicePid(), scm);
                         scms.put( scm, mergeProperties( pid.getServicePid())  );
                         created = true;
@@ -387,7 +387,7 @@ public class ConfigurableComponentHolder
                     }
                     else
                     {
-                        m_singleComponent = createComponentManager();
+                        m_singleComponent = createComponentManager(false);
                         scms.put( m_singleComponent, mergeProperties( pid.getServicePid()
) );
                         created = true;
                     }
@@ -440,7 +440,8 @@ public class ConfigurableComponentHolder
         }
         for (int i = 0; i < m_configurations.length; i++)
         {
-            if ( m_factoryPidIndex != null && i == m_factoryPidIndex)
+            if ( m_factoryPidIndex != null && i == m_factoryPidIndex
+                && !( m_componentMetadata.isObsoleteFactoryComponentFactory() &&
servicePid == null)) //obsolete special case
             {
                 copyTo(properties, m_factoryConfigurations.get(servicePid));
                 if (isDS13)
@@ -598,16 +599,16 @@ public class ConfigurableComponentHolder
         {
             if ( isSatisfied() )
             {
-                if ( m_factoryPidIndex == null)
+                if ( m_factoryPidIndex == null || m_componentMetadata.isObsoleteFactoryComponentFactory())
                 {
-                    m_singleComponent = createComponentManager();
+                    m_singleComponent = createComponentManager(false);
                     cms.add( m_singleComponent );
                     m_singleComponent.reconfigure(mergeProperties( null ), false);
                 }
-                else
+                if ( m_factoryPidIndex != null)
                 {
                     for (String pid: m_factoryConfigurations.keySet()) {
-                        AbstractComponentManager<S> scm = createComponentManager();
+                        AbstractComponentManager<S> scm = createComponentManager(true);
                         m_components.put(pid, scm);
                         scm.reconfigure( mergeProperties( pid ), false);
                         cms.add( scm );

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/impl/config/ConfiguredComponentHolderTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/impl/config/ConfiguredComponentHolderTest.java?rev=1602648&r1=1602647&r2=1602648&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/impl/config/ConfiguredComponentHolderTest.java
(original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/impl/config/ConfiguredComponentHolderTest.java
Sun Jun 15 01:10:25 2014
@@ -236,7 +236,7 @@ public class ConfiguredComponentHolderTe
         }
 
 
-        protected SingleComponentManager createComponentManager()
+        protected SingleComponentManager createComponentManager(boolean factoryConfiguration)
         {
             return new MockImmediateComponentManager( this );
         }

Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ConfigurationComponentFactoryTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ConfigurationComponentFactoryTest.java?rev=1602648&r1=1602647&r2=1602648&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ConfigurationComponentFactoryTest.java
(original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/integration/ConfigurationComponentFactoryTest.java
Sun Jun 15 01:10:25 2014
@@ -82,7 +82,7 @@ public class ConfigurationComponentFacto
 
         // modify the configuration
         Configuration config = getConfigurationAdmin().getConfiguration( factoryConfigPid
);
-        Dictionary props = config.getProperties();
+        Dictionary<String, Object> props = config.getProperties();
         props.put( PROP_NAME, PROP_NAME_FACTORY );
         config.update( props );
         delay();
@@ -98,12 +98,9 @@ public class ConfigurationComponentFacto
         disableAndCheck(componentname);
         delay();
 
-        // factory is disabled and so is the instance
-        // enabled the factory
-        getConfigurationsDisabledThenEnable(componentname, 0, -1);
+        // enabled the factory, factory configuration results in component instance
+        getConfigurationsDisabledThenEnable(componentname, 1, ComponentConfigurationDTO.ACTIVE);
 
-        // check registered components
-        checkConfigurationCount(componentname, 1, ComponentConfigurationDTO.ACTIVE);
 
         // delete the configuration
         getConfigurationAdmin().getConfiguration( factoryConfigPid ).delete();

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=1602648&r1=1602647&r2=1602648&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 Sun
Jun 15 01:10:25 2014
@@ -22,6 +22,7 @@
     <!-- Component Factory Instances -->
     <scr:component name="factory.component"
         enabled="false"
+        modified="modified"
         factory="factory.component.factory" >
         <implementation class="org.apache.felix.scr.integration.components.SimpleComponent"
/>
     </scr:component>



Mime
View raw message