felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r945596 - /felix/trunk/karaf/features/core/src/main/java/org/apache/felix/karaf/features/internal/FeaturesServiceImpl.java
Date Tue, 18 May 2010 11:34:52 GMT
Author: gnodet
Date: Tue May 18 11:34:52 2010
New Revision: 945596

URL: http://svn.apache.org/viewvc?rev=945596&view=rev
Log:
FELIX-2347: Configurations on features should not override existing configurations

Modified:
    felix/trunk/karaf/features/core/src/main/java/org/apache/felix/karaf/features/internal/FeaturesServiceImpl.java

Modified: felix/trunk/karaf/features/core/src/main/java/org/apache/felix/karaf/features/internal/FeaturesServiceImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/features/core/src/main/java/org/apache/felix/karaf/features/internal/FeaturesServiceImpl.java?rev=945596&r1=945595&r2=945596&view=diff
==============================================================================
--- felix/trunk/karaf/features/core/src/main/java/org/apache/felix/karaf/features/internal/FeaturesServiceImpl.java
(original)
+++ felix/trunk/karaf/features/core/src/main/java/org/apache/felix/karaf/features/internal/FeaturesServiceImpl.java
Tue May 18 11:34:52 2010
@@ -375,13 +375,16 @@ public class FeaturesServiceImpl impleme
         for (String config : feature.getConfigurations().keySet()) {
             Dictionary<String,String> props = new Hashtable<String, String>(feature.getConfigurations().get(config));
             String[] pid = parsePid(config);
-            String key = (pid[1] == null ? pid[0] : pid[0] + "-" + pid[1]);
-            props.put(CONFIG_KEY, key);
-            Configuration cfg = getConfiguration(configAdmin, pid[0], pid[1]);
-            if (cfg.getBundleLocation() != null) {
-                cfg.setBundleLocation(null);
+            Configuration cfg = findExistingConfiguration(configAdmin, pid[0], pid[1]);
+            if (cfg == null) {
+                cfg = createConfiguration(configAdmin, pid[0], pid[1]);
+                String key = (pid[1] == null ? pid[0] : pid[0] + "-" + pid[1]);
+                props.put(CONFIG_KEY, key);
+                if (cfg.getBundleLocation() != null) {
+                    cfg.setBundleLocation(null);
+                }
+                cfg.update(props);
             }
-            cfg.update(props);
         }
         Set<Long> bundles = new HashSet<Long>();
         for (String bundleLocation : feature.getBundles()) {
@@ -703,24 +706,24 @@ public class FeaturesServiceImpl impleme
         }
     }
 
-    protected Configuration getConfiguration(ConfigurationAdmin configurationAdmin,
-                                             String pid, String factoryPid) throws IOException,
InvalidSyntaxException {
-        Configuration oldConfiguration = findExistingConfiguration(configurationAdmin, pid,
factoryPid);
-        if (oldConfiguration != null) {
-            return oldConfiguration;
+    protected Configuration createConfiguration(ConfigurationAdmin configurationAdmin,
+                                                String pid, String factoryPid) throws IOException,
InvalidSyntaxException {
+        if (factoryPid != null) {
+            return configurationAdmin.createFactoryConfiguration(pid, null);
         } else {
-            if (factoryPid != null) {
-                return configurationAdmin.createFactoryConfiguration(pid, null);
-            } else {
-                return configurationAdmin.getConfiguration(pid, null);
-            }
+            return configurationAdmin.getConfiguration(pid, null);
         }
     }
 
     protected Configuration findExistingConfiguration(ConfigurationAdmin configurationAdmin,
                                                       String pid, String factoryPid) throws
IOException, InvalidSyntaxException {
         String key = (factoryPid == null ? pid : pid + "-" + factoryPid);
-        String filter = "(" + CONFIG_KEY + "=" + key + ")";
+        String filter;
+        if (factoryPid == null) {
+            filter = "(" + Constants.SERVICE_PID + "=" + pid + ")";
+        } else {
+            filter = "(" + ConfigurationAdmin.SERVICE_FACTORYPID + "=" + factoryPid + ")";
+        }
         Configuration[] configurations = configurationAdmin.listConfigurations(filter);
         if (configurations != null && configurations.length > 0)
         {



Mime
View raw message