Repository: karaf-cellar
Updated Branches:
  refs/heads/master 529c16083 -> 5e97cb14a


[KARAF-3051] Refactoring of Cellar config module (commands/MBean) to use the 
Karaf 3.x syntax.


Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/5e97cb14
Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/5e97cb14
Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/5e97cb14

Branch: refs/heads/master
Commit: 5e97cb14a84d14a5ab55ab568d0292d80185a570
Parents: 529c160
Author: Jean-Baptiste Onofré <[email protected]>
Authored: Tue Jun 17 16:48:45 2014 +0200
Committer: Jean-Baptiste Onofré <[email protected]>
Committed: Tue Jun 17 16:48:45 2014 +0200

----------------------------------------------------------------------
 .../config/management/CellarConfigMBean.java    |  7 ++++---
 .../internal/CellarConfigMBeanImpl.java         | 22 ++++++--------------
 .../cellar/config/shell/PropAppendCommand.java  |  2 +-
 .../cellar/config/shell/PropDelCommand.java     |  2 +-
 .../cellar/config/shell/PropListCommand.java    |  7 ++-----
 .../cellar/config/shell/PropSetCommand.java     |  2 +-
 6 files changed, 15 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/5e97cb14/config/src/main/java/org/apache/karaf/cellar/config/management/CellarConfigMBean.java
----------------------------------------------------------------------
diff --git 
a/config/src/main/java/org/apache/karaf/cellar/config/management/CellarConfigMBean.java
 
b/config/src/main/java/org/apache/karaf/cellar/config/management/CellarConfigMBean.java
index e4a9978..e01cd7d 100644
--- 
a/config/src/main/java/org/apache/karaf/cellar/config/management/CellarConfigMBean.java
+++ 
b/config/src/main/java/org/apache/karaf/cellar/config/management/CellarConfigMBean.java
@@ -15,6 +15,7 @@ package org.apache.karaf.cellar.config.management;
 
 import javax.management.openmbean.TabularData;
 import java.util.List;
+import java.util.Map;
 
 /**
  * Describe the operations and attributes available on the Cellar 
configuration MBean.
@@ -28,7 +29,7 @@ public interface CellarConfigMBean {
      * @return the list of configuration PID.
      * @throws Exception in case of retrieval failure.
      */
-    List<String> listConfig(String group) throws Exception;
+    List<String> getConfigs(String group) throws Exception;
 
     /**
      * Delete a configuration from a cluster group.
@@ -37,7 +38,7 @@ public interface CellarConfigMBean {
      * @param pid the configuration PID to delete.
      * @throws Exception in case of deletion failure.
      */
-    void deleteConfig(String group, String pid) throws Exception;
+    void delete(String group, String pid) throws Exception;
 
     /**
      * List the properties of a configuration in a cluster group.
@@ -47,7 +48,7 @@ public interface CellarConfigMBean {
      * @return the list of properties for the configuration.
      * @throws Exception in case of retrieval failure.
      */
-    TabularData listProperties(String group, String pid) throws Exception;
+    Map<String, String> listProperties(String group, String pid) throws 
Exception;
 
     /**
      * Set the value of a property for a configuration in a cluster group.

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/5e97cb14/config/src/main/java/org/apache/karaf/cellar/config/management/internal/CellarConfigMBeanImpl.java
----------------------------------------------------------------------
diff --git 
a/config/src/main/java/org/apache/karaf/cellar/config/management/internal/CellarConfigMBeanImpl.java
 
b/config/src/main/java/org/apache/karaf/cellar/config/management/internal/CellarConfigMBeanImpl.java
index b4cb202..8424ccd 100644
--- 
a/config/src/main/java/org/apache/karaf/cellar/config/management/internal/CellarConfigMBeanImpl.java
+++ 
b/config/src/main/java/org/apache/karaf/cellar/config/management/internal/CellarConfigMBeanImpl.java
@@ -43,7 +43,7 @@ public class CellarConfigMBeanImpl extends StandardMBean 
implements CellarConfig
     }
 
     @Override
-    public List<String> listConfig(String groupName) throws Exception {
+    public List<String> getConfigs(String groupName) throws Exception {
         // check if the group exists
         Group group = groupManager.findGroupByName(groupName);
         if (group == null) {
@@ -61,7 +61,7 @@ public class CellarConfigMBeanImpl extends StandardMBean 
implements CellarConfig
     }
 
     @Override
-    public void deleteConfig(String groupName, String pid) throws Exception {
+    public void delete(String groupName, String pid) throws Exception {
         // check if the group exists
         Group group = groupManager.findGroupByName(groupName);
         if (group == null) {
@@ -98,15 +98,8 @@ public class CellarConfigMBeanImpl extends StandardMBean 
implements CellarConfig
     }
 
     @Override
-    public TabularData listProperties(String groupName, String pid) throws 
Exception {
-
-        CompositeType compositeType = new CompositeType("Property", "Cellar 
Config Property",
-                new String[]{"key", "value"},
-                new String[]{"Property key", "Property value"},
-                new OpenType[]{SimpleType.STRING, SimpleType.STRING});
-        TabularType tableType = new TabularType("Properties", "Table of all 
properties in the configuration PID",
-                compositeType, new String[]{"key"});
-        TabularData table = new TabularDataSupport(tableType);
+    public Map<String, String> listProperties(String groupName, String pid) 
throws Exception {
+        Map<String, String> properties = new HashMap<String, String>();
 
         Map<String, Properties> clusterConfigurations = 
clusterManager.getMap(Constants.CONFIGURATION_MAP + Configurations.SEPARATOR + 
groupName);
         Properties clusterProperties = clusterConfigurations.get(pid);
@@ -115,13 +108,10 @@ public class CellarConfigMBeanImpl extends StandardMBean 
implements CellarConfig
             while (propertyNames.hasMoreElements()) {
                 String key = (String) propertyNames.nextElement();
                 String value = (String) clusterProperties.get(key);
-                CompositeDataSupport data = new 
CompositeDataSupport(compositeType,
-                        new String[]{"key", "value"},
-                        new String[]{key, value});
-                table.put(data);
+                properties.put(key, value);
             }
         }
-        return table;
+        return properties;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/5e97cb14/config/src/main/java/org/apache/karaf/cellar/config/shell/PropAppendCommand.java
----------------------------------------------------------------------
diff --git 
a/config/src/main/java/org/apache/karaf/cellar/config/shell/PropAppendCommand.java
 
b/config/src/main/java/org/apache/karaf/cellar/config/shell/PropAppendCommand.java
index 8cbcba0..a4c6390 100644
--- 
a/config/src/main/java/org/apache/karaf/cellar/config/shell/PropAppendCommand.java
+++ 
b/config/src/main/java/org/apache/karaf/cellar/config/shell/PropAppendCommand.java
@@ -26,7 +26,7 @@ import org.apache.karaf.cellar.core.event.EventType;
 import java.util.Map;
 import java.util.Properties;
 
-@Command(scope = "cluster", name = "config-propappend", description = "Append 
to the property value for a configuration PID in a cluster group")
+@Command(scope = "cluster", name = "config-property-append", description = 
"Append to the property value for a configuration PID in a cluster group")
 public class PropAppendCommand extends ConfigCommandSupport {
 
     @Argument(index = 0, name = "group", description = "The cluster group 
name", required = true, multiValued = false)

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/5e97cb14/config/src/main/java/org/apache/karaf/cellar/config/shell/PropDelCommand.java
----------------------------------------------------------------------
diff --git 
a/config/src/main/java/org/apache/karaf/cellar/config/shell/PropDelCommand.java 
b/config/src/main/java/org/apache/karaf/cellar/config/shell/PropDelCommand.java
index d416949..059a882 100644
--- 
a/config/src/main/java/org/apache/karaf/cellar/config/shell/PropDelCommand.java
+++ 
b/config/src/main/java/org/apache/karaf/cellar/config/shell/PropDelCommand.java
@@ -26,7 +26,7 @@ import org.apache.karaf.cellar.core.event.EventType;
 import java.util.Map;
 import java.util.Properties;
 
-@Command(scope = "cluster", name = "config-propdel", description = "Delete a 
property from a configuration in a cluster group")
+@Command(scope = "cluster", name = "config-property-delete", description = 
"Delete a property from a configuration in a cluster group")
 public class PropDelCommand extends ConfigCommandSupport {
 
     @Argument(index = 0, name = "group", description = "The cluster group 
name", required = true, multiValued = false)

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/5e97cb14/config/src/main/java/org/apache/karaf/cellar/config/shell/PropListCommand.java
----------------------------------------------------------------------
diff --git 
a/config/src/main/java/org/apache/karaf/cellar/config/shell/PropListCommand.java
 
b/config/src/main/java/org/apache/karaf/cellar/config/shell/PropListCommand.java
index 8d8d800..f1bf513 100644
--- 
a/config/src/main/java/org/apache/karaf/cellar/config/shell/PropListCommand.java
+++ 
b/config/src/main/java/org/apache/karaf/cellar/config/shell/PropListCommand.java
@@ -23,11 +23,9 @@ import org.apache.karaf.shell.commands.Command;
 import java.util.Map;
 import java.util.Properties;
 
-@Command(scope = "cluster", name = "config-proplist", description = "List the 
configurations in a cluster group")
+@Command(scope = "cluster", name = "config-property-list", description = "List 
the configurations in 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)
     String groupName;
 
@@ -51,11 +49,10 @@ public class PropListCommand extends CellarCommandSupport {
                 System.err.println("Configuration PID " + pid + " not found in 
cluster group " + groupName);
             } else {
                 System.out.println(String.format("Property list for 
configuration PID " + pid + " for cluster group " + groupName));
-                System.out.println(String.format(OUTPUT_FORMAT, "Key", 
"Value"));
 
                 for (Object key : properties.keySet()) {
                     String value = properties.getProperty((String) key);
-                    System.out.println(String.format(OUTPUT_FORMAT, key, 
value));
+                    System.out.println("   " + key + " = " + value);
                 }
             }
         } else System.err.println("No configuration found in cluster group " + 
groupName);

http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/5e97cb14/config/src/main/java/org/apache/karaf/cellar/config/shell/PropSetCommand.java
----------------------------------------------------------------------
diff --git 
a/config/src/main/java/org/apache/karaf/cellar/config/shell/PropSetCommand.java 
b/config/src/main/java/org/apache/karaf/cellar/config/shell/PropSetCommand.java
index a3f8d4c..a8da140 100644
--- 
a/config/src/main/java/org/apache/karaf/cellar/config/shell/PropSetCommand.java
+++ 
b/config/src/main/java/org/apache/karaf/cellar/config/shell/PropSetCommand.java
@@ -26,7 +26,7 @@ import org.apache.karaf.cellar.core.event.EventType;
 import java.util.Map;
 import java.util.Properties;
 
-@Command(scope = "cluster", name = "config-propset", description = "Set a 
property value for a configuration in a cluster group")
+@Command(scope = "cluster", name = "config-property-set", description = "Set a 
property value for a configuration in a cluster group")
 public class PropSetCommand extends ConfigCommandSupport {
 
     @Argument(index = 0, name = "group", description = "The cluster group 
name", required = true, multiValued = false)

Reply via email to