You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2008/04/30 09:06:03 UTC

svn commit: r652309 - /servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/spring/SpringCommandRegistry.java

Author: gnodet
Date: Wed Apr 30 00:06:03 2008
New Revision: 652309

URL: http://svn.apache.org/viewvc?rev=652309&view=rev
Log:
SMX4KNL-31: Aliases do not work in subshell

Modified:
    servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/spring/SpringCommandRegistry.java

Modified: servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/spring/SpringCommandRegistry.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/spring/SpringCommandRegistry.java?rev=652309&r1=652308&r2=652309&view=diff
==============================================================================
--- servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/spring/SpringCommandRegistry.java (original)
+++ servicemix/smx4/kernel/trunk/gshell/gshell-core/src/main/java/org/apache/geronimo/gshell/spring/SpringCommandRegistry.java Wed Apr 30 00:06:03 2008
@@ -160,10 +160,9 @@
         if (node instanceof GroupNode) {
             if (s.startsWith(ALIAS_PREFIX)) {
                 s = s.substring(ALIAS_PREFIX.length());
-                for (Node n : ((GroupNode) node).nodes()) {
-                    if (n instanceof CommandNode && ((CommandNode) n).getId().equals(s)) {
-                        return n;
-                    }
+                Node n = recursiveFind((GroupNode) node, s);
+                if (n != null) {
+                    return n;
                 }
                 throw new NotFoundException(s);
             }
@@ -180,6 +179,20 @@
         }
     }
 
+    private Node recursiveFind(GroupNode groupNode, String s) {
+        for (Node n : groupNode.nodes()) {
+            if (n instanceof CommandNode && ((CommandNode) n).getId().equals(s)) {
+                return n;
+            } else if (n instanceof GroupNode) {
+                Node n2 = recursiveFind((GroupNode) n, s);
+                if (n2 != null) {
+                    return n2;
+                }
+            }
+        }
+        return null;
+    }
+
     public Node findNode(String path, String searchPath) throws NotFoundException {
         return findNode(path);
     }