You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2018/01/18 12:29:36 UTC

[camel] branch master updated: CAMEL-12156: Camel Karaf commands for routes should flip the order so camel context is first, so the route completion can use the selected camel context to only show routes from that context. And make both arguments as required as they should be.

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new f40c728  CAMEL-12156: Camel Karaf commands for routes should flip the order so camel context is first, so the route completion can use the selected camel context to only show routes from that context. And make both arguments as required as they should be.
f40c728 is described below

commit f40c728e414c087b37939cc0e30d020ec30f2e31
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Jan 18 13:29:14 2018 +0100

    CAMEL-12156: Camel Karaf commands for routes should flip the order so camel context is first, so the route completion can use the selected camel context to only show routes from that context. And make both arguments as required as they should be.
---
 .../apache/camel/karaf/commands/AbstractRouteCommand.java    | 10 +++++-----
 .../camel/karaf/commands/completers/RouteCompleter.java      | 12 +++++++++++-
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/AbstractRouteCommand.java b/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/AbstractRouteCommand.java
index 1f8f723..b90bf3b 100644
--- a/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/AbstractRouteCommand.java
+++ b/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/AbstractRouteCommand.java
@@ -25,12 +25,12 @@ import org.apache.karaf.shell.api.action.Completion;
 
 public abstract class AbstractRouteCommand extends CamelControllerImpl implements Action {
 
-    @Argument(index = 0, name = "route", description = "The Camel route ID or a wildcard expression", required = true, multiValued = false)
-    @Completion(RouteCompleter.class)
-    String route;
-
-    @Argument(index = 1, name = "context", description = "The Camel context name.", required = false, multiValued = false)
+    @Argument(index = 0, name = "context", description = "The Camel context name.", required = true, multiValued = false)
     @Completion(CamelContextCompleter.class)
     String context;
 
+    @Argument(index = 1, name = "route", description = "The Camel route ID or a wildcard expression", required = true, multiValued = false)
+    @Completion(RouteCompleter.class)
+    String route;
+
 }
diff --git a/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/completers/RouteCompleter.java b/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/completers/RouteCompleter.java
index 4fec645..5998d5e 100644
--- a/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/completers/RouteCompleter.java
+++ b/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/completers/RouteCompleter.java
@@ -33,9 +33,19 @@ import org.apache.karaf.shell.support.completers.StringsCompleter;
 public class RouteCompleter extends CamelControllerImpl implements Completer {
 
     public int complete(Session session, CommandLine commandLine, List<String> candidates) {
+
+        // grab selected camel context from the first argument
+        String contextName = null;
+        String[] args = commandLine.getArguments();
+        if (args != null && args.length > 1) {
+            // 0 is the command name itself
+            // 1 is the first argument which is the camel context name
+            contextName = args[1];
+        }
+
         try {
             StringsCompleter delegate = new StringsCompleter();
-            List<Map<String, String>> routes = getRoutes(null);
+            List<Map<String, String>> routes = getRoutes(contextName);
             for (Map<String, String> row : routes) {
                 delegate.getStrings().add(row.get("routeId"));
             }

-- 
To stop receiving notification emails like this one, please contact
['"commits@camel.apache.org" <co...@camel.apache.org>'].