You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2012/05/06 20:46:46 UTC

svn commit: r1334735 - in /karaf/cellar/trunk/config/src/main: java/org/apache/karaf/cellar/config/shell/ resources/OSGI-INF/blueprint/

Author: jbonofre
Date: Sun May  6 18:46:46 2012
New Revision: 1334735

URL: http://svn.apache.org/viewvc?rev=1334735&view=rev
Log:
[KARAF-1403] Add cluster:config-propappend command

Added:
    karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/shell/PropAppendCommand.java
      - copied, changed from r1334563, karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/shell/PropSetCommand.java
Modified:
    karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/shell/ListCommand.java
    karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/shell/PropListCommand.java
    karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/shell/PropSetCommand.java
    karaf/cellar/trunk/config/src/main/resources/OSGI-INF/blueprint/shell-config.xml

Modified: karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/shell/ListCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/shell/ListCommand.java?rev=1334735&r1=1334734&r2=1334735&view=diff
==============================================================================
--- karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/shell/ListCommand.java (original)
+++ karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/shell/ListCommand.java Sun May  6 18:46:46 2012
@@ -22,12 +22,12 @@ import org.apache.karaf.shell.commands.C
 import java.util.Map;
 import java.util.Properties;
 
-@Command(scope = "cluster", name = "config-list", description = "List the configuration PIDs assigned to a cluster group.")
+@Command(scope = "cluster", name = "config-list", description = "List the configuration PIDs assigned to a group")
 public class ListCommand extends ConfigCommandSupport {
 
     protected static final String OUTPUT_FORMAT = "%-40s";
 
-    @Argument(index = 0, name = "group", description = "The cluster group name.", required = true, multiValued = false)
+    @Argument(index = 0, name = "group", description = "The cluster group name", required = true, multiValued = false)
     String groupName;
 
     @Override

Copied: karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/shell/PropAppendCommand.java (from r1334563, karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/shell/PropSetCommand.java)
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/shell/PropAppendCommand.java?p2=karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/shell/PropAppendCommand.java&p1=karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/shell/PropSetCommand.java&r1=1334563&r2=1334735&rev=1334735&view=diff
==============================================================================
--- karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/shell/PropSetCommand.java (original)
+++ karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/shell/PropAppendCommand.java Sun May  6 18:46:46 2012
@@ -25,19 +25,19 @@ import org.apache.karaf.shell.commands.C
 import java.util.Map;
 import java.util.Properties;
 
-@Command(scope = "cluster", name = "config-propset", description = "Sets the a property value for a configuration PID in a cluster group name.")
-public class PropSetCommand extends ConfigCommandSupport {
+@Command(scope = "cluster", name = "config-propappend", description = "Append to the property value for a configuration PID in a cluster group name")
+public class PropAppendCommand extends ConfigCommandSupport {
 
-    @Argument(index = 0, name = "group", description = "The cluster group name.", required = true, multiValued = false)
+    @Argument(index = 0, name = "group", description = "The cluster group name", required = true, multiValued = false)
     String groupName;
 
-    @Argument(index = 1, name = "pid", description = "The configuration PID.", required = true, multiValued = false)
+    @Argument(index = 1, name = "pid", description = "The configuration PID", required = true, multiValued = false)
     String pid;
 
-    @Argument(index = 2, name = "key", description = "The property key.", required = true, multiValued = false)
+    @Argument(index = 2, name = "key", description = "The property key", required = true, multiValued = false)
     String key;
 
-    @Argument(index = 3, name = "value", description = "The property value.", required = true, multiValued = false)
+    @Argument(index = 3, name = "value", description = "The property value", required = true, multiValued = false)
     String value;
 
     private EventProducer eventProducer;
@@ -64,7 +64,15 @@ public class PropSetCommand extends Conf
             if (properties == null) {
                 properties = new Properties();
             }
-            properties.put(key, value);
+            Object currentValue = properties.get(key);
+            if (currentValue == null) {
+                properties.put(key, value);
+            } else if (currentValue instanceof String) {
+                properties.put(key, currentValue + value);
+            } else {
+                System.err.println("Append failed: current value is not a String");
+                return null;
+            }
             configurationMap.put(pid, properties);
 
             // broadcast the cluster event

Modified: karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/shell/PropListCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/shell/PropListCommand.java?rev=1334735&r1=1334734&r2=1334735&view=diff
==============================================================================
--- karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/shell/PropListCommand.java (original)
+++ karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/shell/PropListCommand.java Sun May  6 18:46:46 2012
@@ -23,15 +23,15 @@ import org.apache.karaf.shell.commands.C
 import java.util.Map;
 import java.util.Properties;
 
-@Command(scope = "cluster", name = "config-proplist", description = "List the properties in a configuration PID assigned to a cluster group.")
+@Command(scope = "cluster", name = "config-proplist", description = "List the configuration PIDs assigned to a cluster group")
 public class PropListCommand extends CellarCommandSupport {
 
     protected static final String OUTPUT_FORMAT = "%-40s %s";
 
-    @Argument(index = 0, name = "group", description = "The cluster group name.", required = true, multiValued = false)
+    @Argument(index = 0, name = "group", description = "The cluster group name", required = true, multiValued = false)
     String groupName;
 
-    @Argument(index = 1, name = "pid", description = "The configuration PID.", required = true, multiValued = false)
+    @Argument(index = 1, name = "pid", description = "The configuration PID", required = true, multiValued = false)
     String pid;
 
     @Override

Modified: karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/shell/PropSetCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/shell/PropSetCommand.java?rev=1334735&r1=1334734&r2=1334735&view=diff
==============================================================================
--- karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/shell/PropSetCommand.java (original)
+++ karaf/cellar/trunk/config/src/main/java/org/apache/karaf/cellar/config/shell/PropSetCommand.java Sun May  6 18:46:46 2012
@@ -25,19 +25,19 @@ import org.apache.karaf.shell.commands.C
 import java.util.Map;
 import java.util.Properties;
 
-@Command(scope = "cluster", name = "config-propset", description = "Sets the a property value for a configuration PID in a cluster group name.")
+@Command(scope = "cluster", name = "config-propset", description = "Sets the a property value for a configuration PID assigned to a cluster group")
 public class PropSetCommand extends ConfigCommandSupport {
 
-    @Argument(index = 0, name = "group", description = "The cluster group name.", required = true, multiValued = false)
+    @Argument(index = 0, name = "group", description = "The cluster group name", required = true, multiValued = false)
     String groupName;
 
-    @Argument(index = 1, name = "pid", description = "The configuration PID.", required = true, multiValued = false)
+    @Argument(index = 1, name = "pid", description = "The configuration PID", required = true, multiValued = false)
     String pid;
 
-    @Argument(index = 2, name = "key", description = "The property key.", required = true, multiValued = false)
+    @Argument(index = 2, name = "key", description = "The property key", required = true, multiValued = false)
     String key;
 
-    @Argument(index = 3, name = "value", description = "The property value.", required = true, multiValued = false)
+    @Argument(index = 3, name = "value", description = "The property value", required = true, multiValued = false)
     String value;
 
     private EventProducer eventProducer;

Modified: karaf/cellar/trunk/config/src/main/resources/OSGI-INF/blueprint/shell-config.xml
URL: http://svn.apache.org/viewvc/karaf/cellar/trunk/config/src/main/resources/OSGI-INF/blueprint/shell-config.xml?rev=1334735&r1=1334734&r2=1334735&view=diff
==============================================================================
--- karaf/cellar/trunk/config/src/main/resources/OSGI-INF/blueprint/shell-config.xml (original)
+++ karaf/cellar/trunk/config/src/main/resources/OSGI-INF/blueprint/shell-config.xml Sun May  6 18:46:46 2012
@@ -45,6 +45,16 @@
                 <ref component-id="allGroupCompleter"/>
             </completers>
         </command>
+        <command name="cluster/config-propappend">
+            <action class="org.apache.karaf.cellar.config.shell.PropAppendCommand">
+                <property name="clusterManager" ref="clusterManager"/>
+                <property name="groupManager" ref="groupManager"/>
+                <property name="eventProducer" ref="eventProducer"/>
+            </action>
+            <completers>
+                <ref component-id="allGroupCompleter"/>
+            </completers>
+        </command>
         <command name="cluster/config-delete">
             <action class="org.apache.karaf.cellar.config.shell.DeleteCommand">
                 <property name="clusterManager" ref="clusterManager"/>