Revision: 5452 http://jnode.svn.sourceforge.net/jnode/?rev=5452&view=rev Author: crawley Date: 2009-05-06 15:12:21 +0000 (Wed, 06 May 2009)
Log Message: ----------- Some reorganization and API simplification to make it easier to fix a problem in the isolate invoker (tomorrow). Modified Paths: -------------- trunk/shell/src/shell/org/jnode/shell/AsyncCommandInvoker.java trunk/shell/src/shell/org/jnode/shell/CommandInvoker.java trunk/shell/src/shell/org/jnode/shell/CommandShell.java trunk/shell/src/shell/org/jnode/shell/DefaultCommandInvoker.java trunk/shell/src/shell/org/jnode/shell/DefaultInterpreter.java trunk/shell/src/shell/org/jnode/shell/RedirectingInterpreter.java trunk/shell/src/shell/org/jnode/shell/SimpleCommandInvoker.java trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java trunk/shell/src/shell/org/jnode/shell/bjorne/SimpleCommandNode.java trunk/shell/src/shell/org/jnode/shell/isolate/IsolateCommandInvoker.java trunk/shell/src/shell/org/jnode/shell/proclet/ProcletCommandInvoker.java Modified: trunk/shell/src/shell/org/jnode/shell/AsyncCommandInvoker.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/AsyncCommandInvoker.java 2009-05-06 11:15:06 UTC (rev 5451) +++ trunk/shell/src/shell/org/jnode/shell/AsyncCommandInvoker.java 2009-05-06 15:12:21 UTC (rev 5452) @@ -51,7 +51,7 @@ public abstract class AsyncCommandInvoker implements SimpleCommandInvoker, KeyboardListener { - CommandShell commandShell; + protected final CommandShell shell; static final Class<?>[] MAIN_ARG_TYPES = new Class[] {String[].class}; @@ -70,27 +70,28 @@ CommandThread threadProcess = null; String cmdName; - public AsyncCommandInvoker(CommandShell commandShell) { - this.commandShell = commandShell; + public AsyncCommandInvoker(CommandShell shell) { + this.shell = shell; // listen for ctrl-c - if (commandShell.getConsole() != null) { - commandShell.getConsole().addKeyboardListener(this); + if (shell.getConsole() != null) { + shell.getConsole().addKeyboardListener(this); } // FIXME ... we need to figure out when / how to detach the listener. // At the moment they probably stay attached for ever. That is not // great if lots of invokers are created. } - public int invoke(CommandLine cmdLine, CommandInfo cmdInfo) throws ShellException { - CommandRunner cr = setup(cmdLine, cmdInfo); - return runIt(cmdLine, cmdInfo, cr); + public int invoke(CommandLine commandLine) throws ShellException { + CommandInfo cmdInfo = commandLine.parseCommandLine(shell); + CommandRunner cr = setup(commandLine, cmdInfo); + return runIt(commandLine, cmdInfo, cr); } - public CommandThread invokeAsynchronous(CommandLine cmdLine, CommandInfo cmdInfo) - throws ShellException { - CommandRunner cr = setup(cmdLine, cmdInfo); - return forkIt(cmdLine, cmdInfo, cr); + public CommandThread invokeAsynchronous(CommandLine commandLine) throws ShellException { + CommandInfo cmdInfo = commandLine.parseCommandLine(shell); + CommandRunner cr = setup(commandLine, cmdInfo); + return forkIt(commandLine, cmdInfo, cr); } protected CommandRunner setup(CommandLine cmdLine, CommandInfo cmdInfo) @@ -109,7 +110,7 @@ ios[Command.STD_OUT] != CommandLine.DEFAULT_STDOUT || ios[Command.STD_ERR] != CommandLine.DEFAULT_STDERR; try { - commandShell.resolveStreams(ios); + shell.resolveStreams(ios); } catch (ClassCastException ex) { throw new ShellFailureException("streams array broken", ex); } @@ -264,6 +265,6 @@ @Override public boolean isDebugEnabled() { - return commandShell.isDebugEnabled(); + return shell.isDebugEnabled(); } } Modified: trunk/shell/src/shell/org/jnode/shell/CommandInvoker.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandInvoker.java 2009-05-06 11:15:06 UTC (rev 5451) +++ trunk/shell/src/shell/org/jnode/shell/CommandInvoker.java 2009-05-06 15:12:21 UTC (rev 5452) @@ -36,7 +36,6 @@ * * @param commandLine this provides the command name (alias), the command * arguments and (where relevant) the command's i/o stream context. - * @param cmdInfo a CommandInfo descriptor for the command to be run. * @param sysProps a Properties object containing the command's system * properties. If this parameter is {...@code null}, a copy of the * system properties for the calling context should be used. @@ -47,8 +46,7 @@ * non-zero indicating command failure. * @throws ShellException if there was some problem launching the command. */ - int invoke(CommandLine commandLine, CommandInfo cmdInfo, - Properties sysProps, Map<String, String> env) + int invoke(CommandLine commandLine, Properties sysProps, Map<String, String> env) throws ShellException; /** @@ -57,7 +55,6 @@ * * @param commandLine this provides the command name (alias), the command * arguments and (where relevant) the command's i/o stream context. - * @param cmdInfo a CommandInfo descriptor for the command to be run. * @param sysProps a Properties object containing the command's system * properties. If this parameter is {...@code null}, a copy of the * system properties for the calling context should be used. @@ -69,8 +66,8 @@ * execute. * @throws ShellException if there was some problem launching the command. */ - CommandThread invokeAsynchronous(CommandLine commandLine, CommandInfo cmdInfo, + CommandThread invokeAsynchronous(CommandLine commandLine, Properties sysProps, Map<String, String> env) throws ShellException; - + } Modified: trunk/shell/src/shell/org/jnode/shell/CommandShell.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2009-05-06 11:15:06 UTC (rev 5451) +++ trunk/shell/src/shell/org/jnode/shell/CommandShell.java 2009-05-06 15:12:21 UTC (rev 5452) @@ -638,13 +638,12 @@ * @return the command's return code * @throws ShellException */ - public int invoke(CommandLine cmdLine, CommandInfo cmdInfo, - Properties sysProps, Map<String, String> env) + public int invoke(CommandLine cmdLine, Properties sysProps, Map<String, String> env) throws ShellException { if (this.invoker instanceof CommandInvoker) { - return ((CommandInvoker) this.invoker).invoke(cmdLine, cmdInfo, sysProps, env); + return ((CommandInvoker) this.invoker).invoke(cmdLine, sysProps, env); } else { - return this.invoker.invoke(cmdLine, cmdInfo); + return this.invoker.invoke(cmdLine); } } @@ -657,9 +656,9 @@ * @return the command's return code * @throws ShellException */ - public CommandThread invokeAsynchronous(CommandLine cmdLine, CommandInfo cmdInfo) + public CommandThread invokeAsynchronous(CommandLine cmdLine) throws ShellException { - return this.invoker.invokeAsynchronous(cmdLine, cmdInfo); + return this.invoker.invokeAsynchronous(cmdLine); } public CommandInfo getCommandInfo(String cmd) throws ShellException { Modified: trunk/shell/src/shell/org/jnode/shell/DefaultCommandInvoker.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/DefaultCommandInvoker.java 2009-05-06 11:15:06 UTC (rev 5451) +++ trunk/shell/src/shell/org/jnode/shell/DefaultCommandInvoker.java 2009-05-06 15:12:21 UTC (rev 5452) @@ -74,11 +74,12 @@ public String getName() { return "default"; } - + /** * Invoke the command. */ - public int invoke(CommandLine cmdLine, CommandInfo cmdInfo) { + public int invoke(CommandLine cmdLine) throws ShellException { + CommandInfo cmdInfo = cmdLine.parseCommandLine(shell); String cmdName = cmdLine.getCommandName(); if (cmdName == null) { return 0; @@ -148,11 +149,11 @@ } return 1; } - + /** * This method is not supported for the DefaultCommandInvoker. */ - public CommandThread invokeAsynchronous(CommandLine commandLine, CommandInfo cmdInfo) { + public CommandThread invokeAsynchronous(CommandLine commandLine) throws ShellException { throw new UnsupportedOperationException(); } Modified: trunk/shell/src/shell/org/jnode/shell/DefaultInterpreter.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/DefaultInterpreter.java 2009-05-06 11:15:06 UTC (rev 5451) +++ trunk/shell/src/shell/org/jnode/shell/DefaultInterpreter.java 2009-05-06 15:12:21 UTC (rev 5452) @@ -101,8 +101,7 @@ return 0; } try { - CommandInfo cmdInfo = cmd.parseCommandLine(shell); - return shell.invoke(cmd, cmdInfo, null, null); + return shell.invoke(cmd, null, null); } catch (CommandSyntaxException ex) { throw new ShellException("Command arguments don't match syntax", ex); } Modified: trunk/shell/src/shell/org/jnode/shell/RedirectingInterpreter.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/RedirectingInterpreter.java 2009-05-06 11:15:06 UTC (rev 5451) +++ trunk/shell/src/shell/org/jnode/shell/RedirectingInterpreter.java 2009-05-06 15:12:21 UTC (rev 5452) @@ -246,8 +246,7 @@ } desc.commandLine.setStreams(new CommandIO[] {in, out, err, CommandLine.DEFAULT_STDERR}); try { - CommandInfo cmdInfo = desc.commandLine.parseCommandLine(shell); - return shell.invoke(desc.commandLine, cmdInfo, null, null); + return shell.invoke(desc.commandLine, null, null); } catch (CommandSyntaxException ex) { throw new ShellException( "Command arguments don't match syntax", ex); @@ -351,9 +350,7 @@ } desc.commandLine.setStreams(new CommandIO[] {in, out, err, CommandLine.DEFAULT_STDERR}); try { - CommandInfo cmdInfo = desc.commandLine.parseCommandLine(shell); - desc.thread = - shell.invokeAsynchronous(desc.commandLine, cmdInfo); + desc.thread = shell.invokeAsynchronous(desc.commandLine); } catch (UnsupportedOperationException ex) { throw new ShellInvocationException( "The current invoker does not support pipelines", ex); Modified: trunk/shell/src/shell/org/jnode/shell/SimpleCommandInvoker.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/SimpleCommandInvoker.java 2009-05-06 11:15:06 UTC (rev 5451) +++ trunk/shell/src/shell/org/jnode/shell/SimpleCommandInvoker.java 2009-05-06 15:12:21 UTC (rev 5452) @@ -44,13 +44,11 @@ * * @param commandLine this provides the command name (alias), the command * arguments and (where relevant) the command's i/o stream context. - * @param cmdInfo a CommandInfo descriptor for the command to be run. * @return an integer return code, with zero indicating command success, * non-zero indicating command failure. * @throws ShellException if there was some problem launching the command. */ - int invoke(CommandLine commandLine, CommandInfo cmdInfo) - throws ShellException; + int invoke(CommandLine commandLine) throws ShellException; /** * Create a thread for running a command asynchronously. This can be used @@ -58,13 +56,12 @@ * * @param commandLine this provides the command name (alias), the command * arguments and (where relevant) the command's i/o stream context. - * @param cmdInfo a CommandInfo descriptor for the command to be run. * @return the thread for the command. Calling * {...@link java.lang.Thread#start()} will cause the command to * execute. * @throws ShellException if there was some problem launching the command. */ - CommandThread invokeAsynchronous(CommandLine commandLine, CommandInfo cmdInfo) + CommandThread invokeAsynchronous(CommandLine commandLine) throws ShellException; /** Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-05-06 11:15:06 UTC (rev 5451) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneContext.java 2009-05-06 15:12:21 UTC (rev 5452) @@ -58,9 +58,9 @@ import org.jnode.shell.ShellFailureException; import org.jnode.shell.ShellSyntaxException; import org.jnode.shell.io.CommandIO; +import org.jnode.shell.io.CommandIOHolder; import org.jnode.shell.io.CommandInput; import org.jnode.shell.io.CommandOutput; -import org.jnode.shell.io.CommandIOHolder; /** * This class holds the shell variable and stream state for a bjorne shell Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-05-06 11:15:06 UTC (rev 5451) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/BjorneInterpreter.java 2009-05-06 15:12:21 UTC (rev 5452) @@ -45,7 +45,6 @@ import java.util.Properties; import org.jnode.driver.console.CompletionInfo; -import org.jnode.shell.CommandInfo; import org.jnode.shell.CommandInterpreter; import org.jnode.shell.CommandLine; import org.jnode.shell.CommandShell; @@ -351,8 +350,7 @@ } else { cmdLine.setStreams(streams); try { - CommandInfo cmdInfo = cmdLine.parseCommandLine(shell); - return shell.invoke(cmdLine, cmdInfo, sysProps, env); + return shell.invoke(cmdLine, sysProps, env); } catch (CommandSyntaxException ex) { throw new ShellException("Command arguments don't match syntax", ex); } Modified: trunk/shell/src/shell/org/jnode/shell/bjorne/SimpleCommandNode.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/bjorne/SimpleCommandNode.java 2009-05-06 11:15:06 UTC (rev 5451) +++ trunk/shell/src/shell/org/jnode/shell/bjorne/SimpleCommandNode.java 2009-05-06 15:12:21 UTC (rev 5452) @@ -21,7 +21,6 @@ package org.jnode.shell.bjorne; import org.jnode.driver.console.CompletionInfo; -import org.jnode.shell.CommandInfo; import org.jnode.shell.CommandLine; import org.jnode.shell.CommandShell; import org.jnode.shell.CommandThread; @@ -130,8 +129,7 @@ throws ShellException { CommandLine command = context.buildCommandLine(getWords()); command.setStreams(context.getIOs()); - CommandInfo cmdInfo = command.parseCommandLine(shell); - return shell.invokeAsynchronous(command, cmdInfo); + return shell.invokeAsynchronous(command); } @Override Modified: trunk/shell/src/shell/org/jnode/shell/isolate/IsolateCommandInvoker.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/isolate/IsolateCommandInvoker.java 2009-05-06 11:15:06 UTC (rev 5451) +++ trunk/shell/src/shell/org/jnode/shell/isolate/IsolateCommandInvoker.java 2009-05-06 15:12:21 UTC (rev 5452) @@ -57,23 +57,22 @@ super(commandShell); } - @Override public String getName() { return "isolate"; } - - public int invoke(CommandLine cmdLine, CommandInfo cmdInfo, - Properties sysProps, Map<String, String> env) + + public int invoke(CommandLine commandLine, Properties sysProps, Map<String, String> env) throws ShellException { - CommandRunner cr = setup(cmdLine, cmdInfo, sysProps, env); - return runIt(cmdLine, cmdInfo, cr); + CommandInfo cmdInfo = commandLine.parseCommandLine(shell); + CommandRunner cr = setup(commandLine, cmdInfo, sysProps, env); + return runIt(commandLine, cmdInfo, cr); } - public CommandThread invokeAsynchronous(CommandLine cmdLine, CommandInfo cmdInfo, - Properties sysProps, Map<String, String> env) - throws ShellException { - CommandRunner cr = setup(cmdLine, cmdInfo, sysProps, env); - return forkIt(cmdLine, cmdInfo, cr); + public CommandThread invokeAsynchronous(CommandLine commandLine, Properties sysProps, + Map<String, String> env) throws ShellException { + CommandInfo cmdInfo = commandLine.parseCommandLine(shell); + CommandRunner cr = setup(commandLine, cmdInfo, sysProps, env); + return forkIt(commandLine, cmdInfo, cr); } @Override Modified: trunk/shell/src/shell/org/jnode/shell/proclet/ProcletCommandInvoker.java =================================================================== --- trunk/shell/src/shell/org/jnode/shell/proclet/ProcletCommandInvoker.java 2009-05-06 11:15:06 UTC (rev 5451) +++ trunk/shell/src/shell/org/jnode/shell/proclet/ProcletCommandInvoker.java 2009-05-06 15:12:21 UTC (rev 5452) @@ -66,19 +66,19 @@ public String getName() { return "proclet"; } - - public int invoke(CommandLine cmdLine, CommandInfo cmdInfo, - Properties sysProps, Map<String, String> env) + + public int invoke(CommandLine commandLine, Properties sysProps, Map<String, String> env) throws ShellException { - CommandRunner cr = setup(cmdLine, cmdInfo, sysProps, env); - return runIt(cmdLine, cmdInfo, cr); + CommandInfo cmdInfo = commandLine.parseCommandLine(shell); + CommandRunner cr = setup(commandLine, cmdInfo, sysProps, env); + return runIt(commandLine, cmdInfo, cr); } - public CommandThread invokeAsynchronous(CommandLine cmdLine, CommandInfo cmdInfo, - Properties sysProps, Map<String, String> env) - throws ShellException { - CommandRunner cr = setup(cmdLine, cmdInfo, sysProps, env); - return forkIt(cmdLine, cmdInfo, cr); + public CommandThread invokeAsynchronous(CommandLine commandLine, Properties sysProps, + Map<String, String> env) throws ShellException { + CommandInfo cmdInfo = commandLine.parseCommandLine(shell); + CommandRunner cr = setup(commandLine, cmdInfo, sysProps, env); + return forkIt(commandLine, cmdInfo, cr); } protected CommandThreadImpl createThread(CommandRunner cr) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your production scanning environment may not be a perfect world - but thanks to Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 Series Scanner you'll get full speed at 300 dpi even with all image processing features enabled. http://p.sf.net/sfu/kodak-com _______________________________________________ Jnode-svn-commits mailing list Jnode-svn-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jnode-svn-commits