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 19:34:53 UTC

svn commit: r1334710 - in /karaf/cellar/branches/cellar-2.2.x/config/src/main: java/org/apache/karaf/cellar/config/shell/ resources/OSGI-INF/blueprint/

Author: jbonofre
Date: Sun May  6 17:34:52 2012
New Revision: 1334710

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

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

Modified: karaf/cellar/branches/cellar-2.2.x/config/src/main/java/org/apache/karaf/cellar/config/shell/ListCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/config/src/main/java/org/apache/karaf/cellar/config/shell/ListCommand.java?rev=1334710&r1=1334709&r2=1334710&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/config/src/main/java/org/apache/karaf/cellar/config/shell/ListCommand.java (original)
+++ karaf/cellar/branches/cellar-2.2.x/config/src/main/java/org/apache/karaf/cellar/config/shell/ListCommand.java Sun May  6 17:34:52 2012
@@ -25,12 +25,12 @@ import java.util.Properties;
 /**
  * List cluster config command.
  */
-@Command(scope = "cluster", name = "config-list", description = "List the configuration PIDs assigned to a 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/branches/cellar-2.2.x/config/src/main/java/org/apache/karaf/cellar/config/shell/PropAppendCommand.java (from r1334562, karaf/cellar/branches/cellar-2.2.x/config/src/main/java/org/apache/karaf/cellar/config/shell/PropSetCommand.java)
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/config/src/main/java/org/apache/karaf/cellar/config/shell/PropAppendCommand.java?p2=karaf/cellar/branches/cellar-2.2.x/config/src/main/java/org/apache/karaf/cellar/config/shell/PropAppendCommand.java&p1=karaf/cellar/branches/cellar-2.2.x/config/src/main/java/org/apache/karaf/cellar/config/shell/PropSetCommand.java&r1=1334562&r2=1334710&rev=1334710&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/config/src/main/java/org/apache/karaf/cellar/config/shell/PropSetCommand.java (original)
+++ karaf/cellar/branches/cellar-2.2.x/config/src/main/java/org/apache/karaf/cellar/config/shell/PropAppendCommand.java Sun May  6 17:34:52 2012
@@ -13,34 +13,31 @@
  */
 package org.apache.karaf.cellar.config.shell;
 
+import org.apache.felix.gogo.commands.Argument;
+import org.apache.felix.gogo.commands.Command;
 import org.apache.karaf.cellar.config.Constants;
 import org.apache.karaf.cellar.config.RemoteConfigurationEvent;
 import org.apache.karaf.cellar.core.Configurations;
 import org.apache.karaf.cellar.core.Group;
-import org.apache.felix.gogo.commands.Argument;
-import org.apache.felix.gogo.commands.Command;
 import org.apache.karaf.cellar.core.control.SwitchStatus;
 import org.apache.karaf.cellar.core.event.EventProducer;
 
 import java.util.Map;
 import java.util.Properties;
 
-/**
- * Config properties set cluster command.
- */
-@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 {
+@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;
@@ -67,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/branches/cellar-2.2.x/config/src/main/java/org/apache/karaf/cellar/config/shell/PropListCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/config/src/main/java/org/apache/karaf/cellar/config/shell/PropListCommand.java?rev=1334710&r1=1334709&r2=1334710&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/config/src/main/java/org/apache/karaf/cellar/config/shell/PropListCommand.java (original)
+++ karaf/cellar/branches/cellar-2.2.x/config/src/main/java/org/apache/karaf/cellar/config/shell/PropListCommand.java Sun May  6 17:34:52 2012
@@ -26,22 +26,22 @@ import java.util.Properties;
 /**
  * Config properties list cluster command.
  */
-@Command(scope = "cluster", name = "config-proplist", description = "List the configuration PIDs 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
     protected Object doExecute() throws Exception {
         Group group = groupManager.findGroupByName(groupName);
         if (group == null) {
-            System.err.println("Cluster group " + groupName + " doesn't exist.");
+            System.err.println("Cluster group " + groupName + " doesn't exist");
             return null;
         }
 

Modified: karaf/cellar/branches/cellar-2.2.x/config/src/main/java/org/apache/karaf/cellar/config/shell/PropSetCommand.java
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/config/src/main/java/org/apache/karaf/cellar/config/shell/PropSetCommand.java?rev=1334710&r1=1334709&r2=1334710&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/config/src/main/java/org/apache/karaf/cellar/config/shell/PropSetCommand.java (original)
+++ karaf/cellar/branches/cellar-2.2.x/config/src/main/java/org/apache/karaf/cellar/config/shell/PropSetCommand.java Sun May  6 17:34:52 2012
@@ -28,19 +28,19 @@ import java.util.Properties;
 /**
  * Config properties set cluster command.
  */
-@Command(scope = "cluster", name = "config-propset", description = "Sets the a property value for a configuration PID assigned to a cluster group.")
+@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/branches/cellar-2.2.x/config/src/main/resources/OSGI-INF/blueprint/shell-config.xml
URL: http://svn.apache.org/viewvc/karaf/cellar/branches/cellar-2.2.x/config/src/main/resources/OSGI-INF/blueprint/shell-config.xml?rev=1334710&r1=1334709&r2=1334710&view=diff
==============================================================================
--- karaf/cellar/branches/cellar-2.2.x/config/src/main/resources/OSGI-INF/blueprint/shell-config.xml (original)
+++ karaf/cellar/branches/cellar-2.2.x/config/src/main/resources/OSGI-INF/blueprint/shell-config.xml Sun May  6 17:34:52 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"/>