felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r783712 - in /felix/trunk/karaf/gshell/gshell-config/src/main: java/org/apache/felix/karaf/gshell/config/ resources/META-INF/spring/ resources/org/apache/felix/karaf/gshell/config/
Date Thu, 11 Jun 2009 09:35:20 GMT
Author: gnodet
Date: Thu Jun 11 09:35:19 2009
New Revision: 783712

URL: http://svn.apache.org/viewvc?rev=783712&view=rev
Log:
FELIX-1206: config/propappend patch

Added:
    felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropAppendCommand.java
    felix/trunk/karaf/gshell/gshell-config/src/main/resources/org/apache/felix/karaf/gshell/config/PropAppendCommand.properties
Modified:
    felix/trunk/karaf/gshell/gshell-config/src/main/resources/META-INF/spring/gshell-config.xml

Added: felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropAppendCommand.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropAppendCommand.java?rev=783712&view=auto
==============================================================================
--- felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropAppendCommand.java
(added)
+++ felix/trunk/karaf/gshell/gshell-config/src/main/java/org/apache/felix/karaf/gshell/config/PropAppendCommand.java
Thu Jun 11 09:35:19 2009
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.felix.karaf.gshell.config;
+
+import java.util.Dictionary;
+
+import org.apache.geronimo.gshell.clp.Argument;
+import org.osgi.service.cm.ConfigurationAdmin;
+
+/**
+ * Appends a value to the current property value.
+ */
+public class PropAppendCommand extends ConfigCommandSupport {
+
+    @Argument(index = 0, required = true, description = "the property to set")
+    String prop;
+
+    @Argument(index = 1, required = true, description = "the value to be appended")
+    String value;
+    
+	@Override
+	protected void doExecute(ConfigurationAdmin admin) throws Exception {
+        Dictionary props = getEditedProps();
+        if (props == null) {
+            System.err.println("No configuration is being edited. Run the edit command first");
+        } else {
+        	final Object currentValue = props.get(prop);
+        	if (currentValue == null) {
+        		props.put(prop, value);
+        	} else if (currentValue instanceof String) {
+        		props.put(prop, currentValue + value);
+        	} else {
+        		System.err.println("Append Failed: current value is not a String.");
+        	}
+        }
+	}
+
+}

Modified: felix/trunk/karaf/gshell/gshell-config/src/main/resources/META-INF/spring/gshell-config.xml
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-config/src/main/resources/META-INF/spring/gshell-config.xml?rev=783712&r1=783711&r2=783712&view=diff
==============================================================================
--- felix/trunk/karaf/gshell/gshell-config/src/main/resources/META-INF/spring/gshell-config.xml
(original)
+++ felix/trunk/karaf/gshell/gshell-config/src/main/resources/META-INF/spring/gshell-config.xml
Thu Jun 11 09:35:19 2009
@@ -78,6 +78,15 @@
                 <null/>
             </gshell:completers>
         </gshell:command>
+        <gshell:command name="config/propappend">
+            <gshell:action class="org.apache.felix.karaf.gshell.config.PropAppendCommand">
+                <property name="bundleContext" ref="bundleContext"/>
+            </gshell:action>
+            <gshell:completers>
+                <ref bean="configPropertyCompleter" />
+                <null/>
+            </gshell:completers>
+        </gshell:command>
         <gshell:command name="config/update">
             <gshell:action class="org.apache.felix.karaf.gshell.config.UpdateCommand">
                 <property name="bundleContext" ref="bundleContext"/>

Added: felix/trunk/karaf/gshell/gshell-config/src/main/resources/org/apache/felix/karaf/gshell/config/PropAppendCommand.properties
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/gshell/gshell-config/src/main/resources/org/apache/felix/karaf/gshell/config/PropAppendCommand.properties?rev=783712&view=auto
==============================================================================
--- felix/trunk/karaf/gshell/gshell-config/src/main/resources/org/apache/felix/karaf/gshell/config/PropAppendCommand.properties
(added)
+++ felix/trunk/karaf/gshell/gshell-config/src/main/resources/org/apache/felix/karaf/gshell/config/PropAppendCommand.properties
Thu Jun 11 09:35:19 2009
@@ -0,0 +1,23 @@
+##
+## Licensed to the Apache Software Foundation (ASF) under one
+## or more contributor license agreements.  See the NOTICE file
+## distributed with this work for additional information
+## regarding copyright ownership.  The ASF licenses this file
+## to you under the Apache License, Version 2.0 (the
+## "License"); you may not use this file except in compliance
+## with the License.  You may obtain a copy of the License at
+##
+##  http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing,
+## software distributed under the License is distributed on an
+## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+## KIND, either express or implied.  See the License for the
+## specific language governing permissions and limitations
+## under the License.
+##
+
+command.description=Appends a value to the end of an existing property value
+
+command.manual=\
+  TODO: date manual



Mime
View raw message