sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomm...@apache.org
Subject svn commit: r1773934 - /sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/component/impl/DefaultDistributionConfigurationManager.java
Date Tue, 13 Dec 2016 09:24:18 GMT
Author: tommaso
Date: Tue Dec 13 09:24:18 2016
New Revision: 1773934

URL: http://svn.apache.org/viewvc?rev=1773934&view=rev
Log:
SLING-6391 - added some javadoc and comments

Modified:
    sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/component/impl/DefaultDistributionConfigurationManager.java

Modified: sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/component/impl/DefaultDistributionConfigurationManager.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/component/impl/DefaultDistributionConfigurationManager.java?rev=1773934&r1=1773933&r2=1773934&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/component/impl/DefaultDistributionConfigurationManager.java
(original)
+++ sling/trunk/contrib/extensions/distribution/core/src/main/java/org/apache/sling/distribution/component/impl/DefaultDistributionConfigurationManager.java
Tue Dec 13 09:24:18 2016
@@ -54,10 +54,10 @@ public class DefaultDistributionConfigur
     @Property(label = "Resource Config Root", description = "The resource config root", value
= "/etc/distribution")
     public static final String CONFIG_ROOT = "resource.config.root";
 
-    @Property(label = "Resource Config Properties", description = "The resource config properties",
value = { "enabled" } )
-    public static final String CONFIG_PROPERTIES= "resource.config.properties";
+    @Property(label = "Resource Config Properties", description = "The resource config properties",
value = {"enabled"})
+    public static final String CONFIG_PROPERTIES = "resource.config.properties";
 
-    @Property(label = "Resource Config Defaults", description = "The default values for resource
config properties", value = { "serializationType=distribution" } )
+    @Property(label = "Resource Config Defaults", description = "The default values for resource
config properties", value = {"serializationType=distribution"})
     public static final String CONFIG_DEFAULTS = "resource.config.defaults";
 
     @Reference
@@ -209,21 +209,32 @@ public class DefaultDistributionConfigur
         return result;
     }
 
+    /**
+     * Split a {@link DistributionConfiguration} into two configurations, so that properties
starting with a certain prefix
+     * go to a separate configuration while the remaining ones will live in a new configuration
+     * @param config a configuration
+     * @param prefix a prefix
+     * @return a {@link Map} of prefix -> configuration
+     */
     static Map<String, DistributionConfiguration> splitConfig(DistributionConfiguration
config, String prefix) {
-        Map<String, Object> properties = config.getProperties();
+        Map<String, Object> distributionConfigurationProperties = config.getProperties();
 
+        // properties for OSGi configuration
         Map<String, Object> defaultMap = new HashMap<String, Object>();
-        Map<String, Object> prefixMap = new HashMap<String, Object>();
 
+        // properties for resource configuration
+        Map<String, Object> prefixMap = new HashMap<String, Object>();
 
-        for (String propertyKey : properties.keySet()) {
-            if (propertyKey.startsWith(prefix)) {
-                prefixMap.put(propertyKey.substring(prefix.length()), properties.get(propertyKey));
+        // split the properties of the given configuration between the OSGi config and the
persisted config
+        for (String configurationPropertyKey : distributionConfigurationProperties.keySet())
{
+            if (configurationPropertyKey.startsWith(prefix)) {
+                prefixMap.put(configurationPropertyKey.substring(prefix.length()), distributionConfigurationProperties.get(configurationPropertyKey));
             } else {
-                defaultMap.put(propertyKey, properties.get(propertyKey));
+                defaultMap.put(configurationPropertyKey, distributionConfigurationProperties.get(configurationPropertyKey));
             }
         }
 
+        // create an OSGi and a persisted configuration
         Map<String, DistributionConfiguration> result = new HashMap<String, DistributionConfiguration>();
         result.put(OSGI_PREFIX, new DistributionConfiguration(config.getKind(), config.getName(),
defaultMap));
         if (prefixMap.size() > 0) {



Mime
View raw message