geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r417097 - in /geronimo/sandbox/gshell/trunk: gshell-api/src/main/java/org/apache/geronimo/gshell/command/ gshell-api/src/main/java/org/apache/geronimo/gshell/util/ gshell-api/src/test/java/org/apache/geronimo/gshell/command/ gshell-cli/src/...
Date Mon, 26 Jun 2006 00:50:28 GMT
Author: jdillon
Date: Sun Jun 25 17:50:27 2006
New Revision: 417097

URL: http://svn.apache.org/viewvc?rev=417097&view=rev
Log:
[GSHELL-2] Refactored to use Object execute(Object[]) as the primary Command.execute signature

Modified:
    geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Command.java
    geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java
    geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/util/Arguments.java
    geronimo/sandbox/gshell/trunk/gshell-api/src/test/java/org/apache/geronimo/gshell/command/CommandSupportTest.java
    geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-scripting-commands/src/main/java/org/apache/geronimo/gshell/commands/scripting/ScriptCommand.java
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/CatCommand.java
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/EchoCommand.java
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/JavaCommand.java
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/SleepCommand.java
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyCommand.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/Shell.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/builtins/ExitCommand.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/builtins/HelpCommand.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/builtins/SetCommand.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/builtins/UnsetCommand.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/ExecutingVisitor.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/MockShell.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/ShellTest.java
    geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-core/src/main/java/org/apache/geronimo/gshell/server/ServerCommand.java

Modified: geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Command.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Command.java?rev=417097&r1=417096&r2=417097&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Command.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Command.java
Sun Jun 25 17:50:27 2006
@@ -33,11 +33,7 @@
 
     void init(CommandContext context); // throws Exception ?
 
-    //
-    // TODO: Return an Object!  Take an Object[]!
-    //
-    
-    int execute(String... args) throws Exception;
+    Object execute(Object... args) throws Exception;
     
     void abort(); // throws Exception ?
     

Modified: geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java?rev=417097&r1=417096&r2=417097&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java
Sun Jun 25 17:50:27 2006
@@ -49,8 +49,11 @@
         setName(name);
     }
 
+    /**
+     * Sub-class <b>must</b> call {@link #setName(String)}.
+     */
     protected CommandSupport() {
-        // Sub-class must call setName()
+        super();
     }
 
     public void setName(final String name) {
@@ -197,21 +200,25 @@
     // Execute Helpers
     //
 
-    public int execute(final String... args) throws Exception {
+    public Object execute(final Object... args) throws Exception {
         assert args != null;
 
         // Make sure that we have been initialized before we go any further
         ensureInitialized();
 
-        log.info("Executing w/arguments: " + Arguments.asString(args));
+        boolean info = log.isInfoEnabled();
+
+        if (info) {
+            log.info("Executing w/arguments: " + Arguments.asString(args));
+        }
 
-        int status;
+        Object result;
 
         try {
             // Handle the command-line
             Options options = getOptions();
             CommandLineParser parser = new PosixParser();
-            CommandLine line = parser.parse(options, args);
+            CommandLine line = parser.parse(options, Arguments.toStringArray(args));
 
             // Custom command-line processing
             boolean usage = processCommandLine(line);
@@ -224,7 +231,7 @@
             }
 
             // Execute with the remaining arguments post-processing
-            status = doExecute(line.getArgs());
+            result = doExecute(line.getArgs());
         }
         catch (Exception e) {
             log.error(e.getMessage());
@@ -232,7 +239,7 @@
                 log.debug("Exception details", e);
             }
 
-            status = Command.FAILURE;
+            result = Command.FAILURE;
         }
         catch (ExitNotification n) {
             //
@@ -247,16 +254,18 @@
                 log.debug("Error details", e);
             }
 
-            status = Command.FAILURE;
+            result = Command.FAILURE;
         }
         finally {
             // Be sure to flush the commands outputs
             getIO().flush();
         }
 
-        log.info("Command exited with status code: " + status);
+        if (info) {
+            log.info("Command exited with result: " + result);
+        }
 
-        return status;
+        return result;
     }
 
     /**
@@ -267,9 +276,10 @@
      *
      * @throws Exception
      */
-    protected int doExecute(final String[] args) throws Exception {
-        return Command.FAILURE;
-    }
+//    protected Object doExecute(final Object[] args) throws Exception {
+//        throw new Error("Not implemented; Command should have overridden doExecute(Object[])");
+//    }
+    protected abstract Object doExecute(final Object[] args) throws Exception;
 
     //
     // CLI Fluff

Modified: geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/util/Arguments.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/util/Arguments.java?rev=417097&r1=417096&r2=417097&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/util/Arguments.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/util/Arguments.java
Sun Jun 25 17:50:27 2006
@@ -23,11 +23,11 @@
  */
 public class Arguments
 {
-    public static String[] shift(final String[] args) {
+    public static Object[] shift(final Object[] args) {
         return shift(args, 1);
     }
 
-    public static String[] shift(final String[] args, int pos) {
+    public static Object[] shift(final Object[] args, int pos) {
         assert args != null;
         assert args.length >= pos;
 
@@ -36,7 +36,7 @@
         return _args;
     }
 
-    public static String asString(final String[] args) {
+    public static String asString(final Object[] args) {
         assert args != null;
 
         StringBuffer buff = new StringBuffer();
@@ -49,5 +49,17 @@
         }
 
         return buff.toString();
+    }
+
+    public static String[] toStringArray(final Object[] args) {
+        assert args != null;
+
+        String[] strings = new String[args.length];
+
+        for (int i=0; i<args.length; i++ ) {
+            strings[i] = String.valueOf(args[i]);
+        }
+
+        return strings;
     }
 }

Modified: geronimo/sandbox/gshell/trunk/gshell-api/src/test/java/org/apache/geronimo/gshell/command/CommandSupportTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-api/src/test/java/org/apache/geronimo/gshell/command/CommandSupportTest.java?rev=417097&r1=417096&r2=417097&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-api/src/test/java/org/apache/geronimo/gshell/command/CommandSupportTest.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-api/src/test/java/org/apache/geronimo/gshell/command/CommandSupportTest.java
Sun Jun 25 17:50:27 2006
@@ -70,5 +70,9 @@
         public MockCommand(final String name) {
             super(name);
         }
+
+        protected Object doExecute(final Object[] args) throws Exception {
+            return null;
+        }
     }
 }

Modified: geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java?rev=417097&r1=417096&r2=417097&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
Sun Jun 25 17:50:27 2006
@@ -236,7 +236,7 @@
             log.debug("Started in " + watch);
         }
 
-        int status = 0;
+        Object result = null;
 
         //
         // TODO: Pass interactive flags (maybe as property) so gshell knows what mode it
is
@@ -264,14 +264,20 @@
             interp.run();
         }
         else {
-            status = gshell.execute(args);
+            result = gshell.execute(args);
         }
 
         if (debug) {
             log.debug("Ran for " + watch);
         }
 
-        System.exit(status);
+        // If the result is a number, then pass that back to the calling shell
+        if (result instanceof Number) {
+            System.exit(((Number)result).intValue());
+        }
+        else {
+            System.exit(0);
+        }
     }
 
     //

Modified: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-scripting-commands/src/main/java/org/apache/geronimo/gshell/commands/scripting/ScriptCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/gshell-scripting-commands/src/main/java/org/apache/geronimo/gshell/commands/scripting/ScriptCommand.java?rev=417097&r1=417096&r2=417097&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-scripting-commands/src/main/java/org/apache/geronimo/gshell/commands/scripting/ScriptCommand.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-scripting-commands/src/main/java/org/apache/geronimo/gshell/commands/scripting/ScriptCommand.java
Sun Jun 25 17:50:27 2006
@@ -89,7 +89,7 @@
         return usage;
     }
 
-    protected int doExecute(final String[] args) throws Exception {
+    protected Object doExecute(final Object[] args) throws Exception {
         assert args != null;
 
         //

Modified: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/CatCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/gshell-standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/CatCommand.java?rev=417097&r1=417096&r2=417097&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/CatCommand.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/CatCommand.java
Sun Jun 25 17:50:27 2006
@@ -26,6 +26,7 @@
 import org.apache.geronimo.gshell.command.MessageSource;
 import org.apache.geronimo.gshell.command.CommandException;
 import org.apache.geronimo.gshell.console.IO;
+import org.apache.geronimo.gshell.util.Arguments;
 
 import java.io.BufferedReader;
 import java.io.File;
@@ -77,7 +78,7 @@
         return usage;
     }
 
-    protected int doExecute(String[] args) throws Exception {
+    protected Object doExecute(Object[] args) throws Exception {
         assert args != null;
 
         // No args, then read from STDIN
@@ -85,7 +86,7 @@
             args = new String[] { "-" };
         }
 
-        cat(args);
+        cat(Arguments.toStringArray(args));
 
         return Command.SUCCESS;
     }

Modified: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/EchoCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/gshell-standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/EchoCommand.java?rev=417097&r1=417096&r2=417097&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/EchoCommand.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/EchoCommand.java
Sun Jun 25 17:50:27 2006
@@ -64,7 +64,7 @@
         return usage;
     }
 
-    protected int doExecute(final String[] args) throws Exception {
+    protected Object doExecute(final Object[] args) throws Exception {
         assert args != null;
 
         IO io = getIO();

Modified: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/JavaCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/gshell-standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/JavaCommand.java?rev=417097&r1=417096&r2=417097&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/JavaCommand.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/JavaCommand.java
Sun Jun 25 17:50:27 2006
@@ -28,7 +28,6 @@
 import org.apache.geronimo.gshell.util.Arguments;
 
 import java.lang.reflect.Method;
-import java.util.Arrays;
 
 /**
  * Execute a Java standard application.
@@ -85,34 +84,39 @@
         return usage;
     }
 
-    protected int doExecute(final String[] args) throws Exception {
+    protected Object doExecute(final Object[] args) throws Exception {
         assert args != null;
 
-        run(args);
+        run(String.valueOf(args[0]), Arguments.toStringArray(Arguments.shift(args)));
 
         return Command.SUCCESS;
     }
 
-    private void run(final String[] args) throws Exception {
-        assert args != null;
-        assert args.length > 0;
-
-        run(args[0], Arguments.shift(args));
-    }
 
     private void run(final String classname, final String[] args) throws Exception {
         assert classname != null;
         assert args != null;
 
+        boolean info = log.isInfoEnabled();
+
         Class type = Thread.currentThread().getContextClassLoader().loadClass(classname);
-        log.info("Using type: " + type);
+        if (info) {
+            log.info("Using type: " + type);
+        }
 
         Method method = type.getMethod(methodName, new Class[] { String[].class });
-        log.info("Using method: " + method);
+        if (info) {
+            log.info("Using method: " + method);
+        }
+
+        if (info) {
+            log.info("Invoking w/arguments: " + Arguments.asString(args));
+        }
 
-        log.info("Invoking w/arguments: " + Arrays.asList(args));
         Object result = method.invoke(null, new Object[] { args });
 
-        log.info("Result: " + result);
+        if (info) {
+            log.info("Result: " + result);
+        }
     }
 }

Modified: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/SleepCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/gshell-standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/SleepCommand.java?rev=417097&r1=417096&r2=417097&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/SleepCommand.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/SleepCommand.java
Sun Jun 25 17:50:27 2006
@@ -56,7 +56,7 @@
         return usage;
     }
 
-    protected int doExecute(String[] args) throws Exception {
+    protected Object doExecute(Object[] args) throws Exception {
         assert args != null;
 
         log.info("Sleeping for " + time);

Modified: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyCommand.java?rev=417097&r1=417096&r2=417097&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyCommand.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs-commands/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyCommand.java
Sun Jun 25 17:50:27 2006
@@ -54,12 +54,12 @@
         return usage;
     }
 
-    protected int doExecute(String[] args) throws Exception {
+    protected Object doExecute(Object[] args) throws Exception {
         assert args != null;
 
         FileSystemManager fsm = getFileSystemManager();
-        FileObject source = fsm.resolveFile(args[0]);
-        FileObject target = fsm.resolveFile(args[1]);
+        FileObject source = fsm.resolveFile(String.valueOf(args[0]));
+        FileObject target = fsm.resolveFile(String.valueOf(args[1]));
 
         log.info("Copying " + source + " -> " + target);
 

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/Shell.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/Shell.java?rev=417097&r1=417096&r2=417097&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/Shell.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/Shell.java
Sun Jun 25 17:50:27 2006
@@ -39,7 +39,7 @@
 import java.util.Iterator;
 
 /**
- * ???
+ * This is the primary interface to executing named commands.
  *
  * @version $Id$
  */
@@ -102,10 +102,12 @@
         return commandManager;
     }
 
-    public int execute(final String commandLine) throws Exception {
+    public Object execute(final String commandLine) throws Exception {
         assert commandLine != null;
 
-        log.info("Executing (String): " + commandLine);
+        if (log.isInfoEnabled()) {
+            log.info("Executing (String): " + commandLine);
+        }
 
         CommandLine cl = commandLineBuilder.create(commandLine);
         cl.execute();
@@ -114,7 +116,7 @@
         // TODO: Fix API to allow CL to pass back data
         //
 
-        return 0;
+        return Command.SUCCESS;
     }
 
     //
@@ -135,13 +137,15 @@
         }
     }
 
-    public int execute(final String commandName, final String[] args) throws Exception {
+    public Object execute(final String commandName, final Object[] args) throws Exception
{
         assert commandName != null;
         assert args != null;
 
         boolean debug = log.isDebugEnabled();
 
-        log.info("Executing (" + commandName + "): " + Arguments.asString(args));
+        if (log.isInfoEnabled()) {
+            log.info("Executing (" + commandName + "): " + Arguments.asString(args));
+        }
 
         // Setup the command container
         ShellContainer container = new ShellContainer(shellContainer);
@@ -194,9 +198,9 @@
             watch.start();
         }
 
-        int status;
+        Object result;
         try {
-            status = cmd.execute(args);
+            result = cmd.execute(args);
 
             if (debug) {
                 log.debug("Command completed in " + watch);
@@ -209,15 +213,17 @@
             // container.stop() container.dispose() ?
         }
 
-        return status;
+        return result;
     }
 
-    public int execute(final String... args) throws Exception {
+    public Object execute(final Object... args) throws Exception {
         assert args != null;
         assert args.length > 1;
 
-        log.info("Executing (String[]): " + Arguments.asString(args));
+        if (log.isInfoEnabled()) {
+            log.info("Executing (Object...): " + Arguments.asString(args));
+        }
 
-        return execute(args[0], Arguments.shift(args));
+        return execute(String.valueOf(args[0]), Arguments.shift(args));
     }
 }

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/builtins/ExitCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/builtins/ExitCommand.java?rev=417097&r1=417096&r2=417097&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/builtins/ExitCommand.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/builtins/ExitCommand.java
Sun Jun 25 17:50:27 2006
@@ -64,7 +64,7 @@
         return usage;
     }
 
-    protected int doExecute(String[] args) throws Exception {
+    protected Object doExecute(Object[] args) throws Exception {
         assert args != null;
 
         log.info("Exiting w/code: " + exitCode);

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/builtins/HelpCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/builtins/HelpCommand.java?rev=417097&r1=417096&r2=417097&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/builtins/HelpCommand.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/builtins/HelpCommand.java
Sun Jun 25 17:50:27 2006
@@ -91,7 +91,7 @@
         return usage;
     }
 
-    protected int doExecute(final String[] args) throws Exception {
+    protected Object doExecute(final Object[] args) throws Exception {
         assert args != null;
 
         IO io = getIO();

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/builtins/SetCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/builtins/SetCommand.java?rev=417097&r1=417096&r2=417097&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/builtins/SetCommand.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/builtins/SetCommand.java
Sun Jun 25 17:50:27 2006
@@ -86,7 +86,7 @@
         return usage;
     }
 
-    protected int doExecute(String[] args) throws Exception {
+    protected Object doExecute(Object[] args) throws Exception {
         assert args != null;
 
         IO io = getIO();
@@ -138,14 +138,16 @@
         // NOTE: May want to make x=b part of the CL grammar
         //
 
-        for (String arg : args) {
+        for (Object arg : args) {
+            String namevalue = String.valueOf(arg);
+
             switch (mode) {
                 case PROPERTY:
-                    setProperty(arg);
+                    setProperty(namevalue);
                     break;
 
                 case VARIABLE:
-                    setVariable(arg);
+                    setVariable(namevalue);
                     break;
             }
         }

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/builtins/UnsetCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/builtins/UnsetCommand.java?rev=417097&r1=417096&r2=417097&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/builtins/UnsetCommand.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/builtins/UnsetCommand.java
Sun Jun 25 17:50:27 2006
@@ -80,17 +80,19 @@
         return usage;
     }
 
-    protected int doExecute(String[] args) throws Exception {
+    protected Object doExecute(Object[] args) throws Exception {
         assert args != null;
 
-        for (String arg : args) {
+        for (Object arg : args) {
+            String namevalue = String.valueOf(arg);
+
             switch (mode) {
                 case PROPERTY:
-                    unsetProperty(arg);
+                    unsetProperty(namevalue);
                     break;
 
                 case VARIABLE:
-                    unsetVariable(arg);
+                    unsetVariable(namevalue);
                     break;
             }
         }

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/ExecutingVisitor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/ExecutingVisitor.java?rev=417097&r1=417096&r2=417097&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/ExecutingVisitor.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/ExecutingVisitor.java
Sun Jun 25 17:50:27 2006
@@ -74,9 +74,7 @@
         // NOTE: Visiting children will execute seperate commands in serial
         //
 
-        Object result = node.childrenAccept(this, data);
-
-        return result;
+        return node.childrenAccept(this, data);
     }
 
     public Object visit(final ASTExpression node, final Object data) {
@@ -84,23 +82,25 @@
         // assert data != null;
 
         // Create the argument list (cmd name + args)
-        List<String> list = new ArrayList<String>(node.jjtGetNumChildren());
+        List<Object> list = new ArrayList<Object>(node.jjtGetNumChildren());
         node.childrenAccept(this, list);
 
-        String[] args = (String[])list.toArray(new String[list.size()]);
+        Object[] args = (Object[])list.toArray(new Object[list.size()]);
         assert list.size() >= 1;
 
-        String commandName = args[0];
+        String commandName = String.valueOf(args[0]);
         args = Arguments.shift(args);
 
-        int result;
+        Object result;
 
         try {
             result = shell.execute(commandName, args);
         }
         catch (Exception e) {
             //
-            // FIXME: !!!
+            // FIXME: Need to resolve how to pass back this exception to the calling code
+            //        Maybe a custom RuntimeException or Error that can be caust by upper
layer
+            //        and then decoded and rethrown?
             //
 
             throw new RuntimeException(e);
@@ -113,7 +113,7 @@
         assert data != null;
         assert data instanceof List;
 
-        List<String> args = (List<String>)data;
+        List<Object> args = (List<Object>)data;
         args.add(value);
 
         return value;

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/MockShell.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/MockShell.java?rev=417097&r1=417096&r2=417097&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/MockShell.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/MockShell.java
Sun Jun 25 17:50:27 2006
@@ -29,7 +29,7 @@
 public class MockShell
     extends Shell
 {
-    public String[] args;
+    public Object[] args;
 
     public String commandName;
 
@@ -37,13 +37,13 @@
         super(new IO());
     }
 
-    public int execute(String... args) throws Exception {
+    public Object execute(Object... args) throws Exception {
         this.args = args;
 
         return 0;
     }
 
-    public int execute(String commandName, String[] args) throws Exception {
+    public Object execute(String commandName, Object[] args) throws Exception {
         this.commandName = commandName;
         this.args = args;
 

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/ShellTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/ShellTest.java?rev=417097&r1=417096&r2=417097&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/ShellTest.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/ShellTest.java
Sun Jun 25 17:50:27 2006
@@ -57,7 +57,7 @@
         Shell shell = new Shell();
 
         try {
-            shell.execute(new String[]{ "foo", "bar", "baz" });
+            shell.execute(new Object[]{ "foo", "bar", "baz" });
         }
         catch (CommandNotFoundException expected) {
             // ignore

Modified: geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-core/src/main/java/org/apache/geronimo/gshell/server/ServerCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-core/src/main/java/org/apache/geronimo/gshell/server/ServerCommand.java?rev=417097&r1=417096&r2=417097&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-core/src/main/java/org/apache/geronimo/gshell/server/ServerCommand.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-core/src/main/java/org/apache/geronimo/gshell/server/ServerCommand.java
Sun Jun 25 17:50:27 2006
@@ -69,7 +69,7 @@
         return usage;
     }
 
-    protected int doExecute(final String[] args) throws Exception {
+    protected Object doExecute(final Object[] args) throws Exception {
         assert args != null;
 
         SocketHandler handler = new SocketHandler() {



Mime
View raw message