You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by cc...@apache.org on 2009/03/16 06:51:38 UTC

svn commit: r754820 - in /servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main: java/org/apache/servicemix/kernel/gshell/admin/internal/completers/ resources/META-INF/spring/

Author: ccustine
Date: Mon Mar 16 05:51:33 2009
New Revision: 754820

URL: http://svn.apache.org/viewvc?rev=754820&view=rev
Log:
SMX4KNL-233 - Add argument completion for core gshell commands
- Added admin commands

Added:
    servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/completers/
    servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/completers/InstanceCompleter.java
Modified:
    servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/resources/META-INF/spring/gshell-admin.xml

Added: servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/completers/InstanceCompleter.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/completers/InstanceCompleter.java?rev=754820&view=auto
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/completers/InstanceCompleter.java (added)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/java/org/apache/servicemix/kernel/gshell/admin/internal/completers/InstanceCompleter.java Mon Mar 16 05:51:33 2009
@@ -0,0 +1,46 @@
+/*
+ * 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.servicemix.kernel.gshell.admin.internal.completers;
+
+import java.util.List;
+
+import org.apache.servicemix.kernel.gshell.admin.AdminService;
+import org.apache.servicemix.kernel.gshell.admin.Instance;
+import org.apache.geronimo.gshell.console.completer.StringsCompleter;
+import jline.Completor;
+
+/**
+ * {@link jline.Completor} for server instance names.
+ *
+ * Displays a list of configured server instances for the Admin commands.
+ *
+ */
+public class InstanceCompleter implements Completor {
+    private AdminService adminService;
+
+    public void setAdminService(AdminService adminService) {
+        this.adminService = adminService;
+    }
+
+    public int complete(String buffer, int cursor, List candidates) {
+        StringsCompleter delegate = new StringsCompleter();
+        for (Instance instance : adminService.getInstances()) {
+            delegate.getStrings().add(instance.getName());
+        }
+        return delegate.complete(buffer, cursor, candidates);
+    }
+}

Modified: servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/resources/META-INF/spring/gshell-admin.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/resources/META-INF/spring/gshell-admin.xml?rev=754820&r1=754819&r2=754820&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/resources/META-INF/spring/gshell-admin.xml (original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-admin/src/main/resources/META-INF/spring/gshell-admin.xml Mon Mar 16 05:51:33 2009
@@ -49,6 +49,10 @@
         <gshell:command name="admin/connect">
             <gshell:action class="org.apache.servicemix.kernel.gshell.admin.internal.commands.ConnectCommand"
                            parent="adminCommandBundleSupport" />
+            <gshell:completers>
+                <ref bean="instanceCompleter" />
+                <null/>
+            </gshell:completers>
         </gshell:command>
         <gshell:command name="admin/list">
             <gshell:action class="org.apache.servicemix.kernel.gshell.admin.internal.commands.ListCommand"
@@ -57,18 +61,34 @@
         <gshell:command name="admin/start">
             <gshell:action class="org.apache.servicemix.kernel.gshell.admin.internal.commands.StartCommand"
                            parent="adminCommandBundleSupport" />
+            <gshell:completers>
+                <ref bean="instanceCompleter" />
+                <null/>
+            </gshell:completers>
         </gshell:command>
         <gshell:command name="admin/stop">
             <gshell:action class="org.apache.servicemix.kernel.gshell.admin.internal.commands.StopCommand"
                            parent="adminCommandBundleSupport" />
+            <gshell:completers>
+                <ref bean="instanceCompleter" />
+                <null/>
+            </gshell:completers>
         </gshell:command>
         <gshell:command name="admin/destroy">
             <gshell:action class="org.apache.servicemix.kernel.gshell.admin.internal.commands.DestroyCommand"
                            parent="adminCommandBundleSupport" />
+            <gshell:completers>
+                <ref bean="instanceCompleter" />
+                <null/>
+            </gshell:completers>
         </gshell:command>
         <gshell:command name="admin/change-port">
             <gshell:action class="org.apache.servicemix.kernel.gshell.admin.internal.commands.ChangePortCommand"
                            parent="adminCommandBundleSupport" />
+            <gshell:completers>
+                <ref bean="instanceCompleter" />
+                <null/>
+            </gshell:completers>
         </gshell:command>
     </gshell:command-bundle>
 
@@ -78,4 +98,9 @@
         <property name="preferences" ref="preferences" />
     </bean>
 
+    <bean id="instanceCompleter" class="org.apache.servicemix.kernel.gshell.admin.internal.completers.InstanceCompleter">
+        <property name="adminService" ref="adminService" />
+    </bean>
+
+
 </beans>
\ No newline at end of file