geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r616979 - in /geronimo/gshell/trunk/gshell-core/src: main/java/org/apache/geronimo/gshell/ main/java/org/apache/geronimo/gshell/layout/ test/java/org/apache/geronimo/gshell/layout/
Date Thu, 31 Jan 2008 01:38:43 GMT
Author: jdillon
Date: Wed Jan 30 17:38:41 2008
New Revision: 616979

URL: http://svn.apache.org/viewvc?rev=616979&view=rev
Log:
(GSHELL-13) Add search path support... yay! Thanks #2

Modified:
    geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultCommandExecutor.java
    geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/DefaultLayoutManager.java
    geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/LayoutManager.java
    geronimo/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/layout/DefaultLayoutManagerTest.java

Modified: geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultCommandExecutor.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultCommandExecutor.java?rev=616979&r1=616978&r2=616979&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultCommandExecutor.java
(original)
+++ geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultCommandExecutor.java
Wed Jan 30 17:38:41 2008
@@ -135,9 +135,11 @@
         assert args != null;
 
         log.info("Executing ({}): [{}]", path, Arguments.asString(args));
-
-        final Node node = layoutManager.findNode(path);
-
+        
+        final String searchPath = (String) env.getVariables().get(LayoutManager.COMMAND_PATH);
+        
+        final Node node = layoutManager.findNode(path, searchPath);
+        
         final String id = findCommandId(node);
 
         final Command command;
@@ -191,7 +193,7 @@
                             //
                             // TODO:
                             //
-
+                            
                             return null;
                         }
                     };

Modified: geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/DefaultLayoutManager.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/DefaultLayoutManager.java?rev=616979&r1=616978&r2=616979&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/DefaultLayoutManager.java
(original)
+++ geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/DefaultLayoutManager.java
Wed Jan 30 17:38:41 2008
@@ -73,14 +73,43 @@
     public Layout getLayout() {
         return layout;
     }
-
+    
     public Node findNode(final String path) throws NotFoundException {
+        return findNode(path, null);
+    }
+
+    public Node findNode(final String path, final String searchPath) throws NotFoundException
{
         assert path != null;
 
         Node start;
 
         if (path.startsWith(PATH_SEPARATOR)) {
             start = layout;
+            return findNode(start, path);
+        }
+        else if (searchPath != null) {
+            String[] pathList = searchPath.split(SEARCH_PATH_SEPARATOR);
+            Node foundNode = null;
+            
+            for (String commandPath : pathList) {
+                try {
+                    Node pathNode = findNode(commandPath);
+                    foundNode = findNode(pathNode, path);
+                    
+                    if (foundNode != null) {
+                        break;
+                    }
+                }
+                catch (NotFoundException e) {
+                    // Ignore this for now.  We might still have paths to check
+                }
+            }
+            
+            if (foundNode == null) {
+                foundNode = findNode(layout, path);
+            }
+            
+            return foundNode;
         }
         else {
             start = (Node) env.getVariables().get(CURRENT_NODE);
@@ -88,9 +117,9 @@
             if (start == null) {
                 start = layout;
             }
+            
+            return findNode(start, path);
         }
-
-        return findNode(start, path);
     }
 
     public Node findNode(final Node start, final String path) throws NotFoundException {

Modified: geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/LayoutManager.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/LayoutManager.java?rev=616979&r1=616978&r2=616979&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/LayoutManager.java
(original)
+++ geronimo/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/LayoutManager.java
Wed Jan 30 17:38:41 2008
@@ -34,11 +34,18 @@
 
     String ROOT = "/";
 
+    // FIXME: Rename, this is a file name sep, not a path sep
     String PATH_SEPARATOR = "/";
+    
+    String COMMAND_PATH = "path";
+    
+    String SEARCH_PATH_SEPARATOR = ":";
 
     Layout getLayout();
 
     Node findNode(String path) throws NotFoundException;
+    
+    Node findNode(String path, String searchPath) throws NotFoundException;
 
     Node findNode(Node start, String path) throws NotFoundException;
 }

Modified: geronimo/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/layout/DefaultLayoutManagerTest.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/layout/DefaultLayoutManagerTest.java?rev=616979&r1=616978&r2=616979&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/layout/DefaultLayoutManagerTest.java
(original)
+++ geronimo/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/layout/DefaultLayoutManagerTest.java
Wed Jan 30 17:38:41 2008
@@ -61,6 +61,11 @@
         Node node = layoutManager.findNode("test/foo");
         assertNotNull(node);
     }
+    
+    public void testFindWithCommandPath() throws Exception {
+        Node node = layoutManager.findNode("foo", "/:test");
+        assertNotNull(node);
+    }
 
     public void testFindNotFound() throws Exception {
         try {



Mime
View raw message