From: <cr...@us...> - 2008-11-09 02:35:52
|
Revision: 4681 http://jnode.svn.sourceforge.net/jnode/?rev=4681&view=rev Author: crawley Date: 2008-11-09 02:35:50 +0000 (Sun, 09 Nov 2008) Log Message: ----------- Converting some commands to use the new 'execute' method Modified Paths: -------------- trunk/distr/src/apps/org/jnode/apps/derby/DerbyCommand.java trunk/distr/src/apps/org/jnode/apps/edit/EditCommand.java trunk/distr/src/apps/org/jnode/apps/editor/LeedCommand.java trunk/distr/src/apps/org/jnode/apps/editor/LeviCommand.java trunk/distr/src/apps/org/jnode/apps/httpd/NanoHTTPDCommand.java trunk/distr/src/apps/org/jnode/apps/jetty/JettyCommand.java trunk/distr/src/apps/org/jnode/apps/jpartition/JPartitionCommand.java trunk/fs/src/driver/org/jnode/driver/block/ramdisk/command/RamDiskCommand.java trunk/fs/src/fs/org/jnode/fs/command/AbstractFormatCommand.java trunk/gui/src/driver/org/jnode/driver/sound/command/BeepCommand.java trunk/gui/src/driver/org/jnode/driver/sound/command/PlayCommand.java Modified: trunk/distr/src/apps/org/jnode/apps/derby/DerbyCommand.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/derby/DerbyCommand.java 2008-11-09 02:34:08 UTC (rev 4680) +++ trunk/distr/src/apps/org/jnode/apps/derby/DerbyCommand.java 2008-11-09 02:35:50 UTC (rev 4681) @@ -43,7 +43,7 @@ new DerbyCommand().execute(args); } - public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err) + public void execute() throws Exception { File home_dir = ARG_HOME.getValue(); String command = FLAG_START.isSet() ? "start" : FLAG_STOP.isSet() ? "stop" : "?"; @@ -53,20 +53,14 @@ NetworkServerControlImpl server = new NetworkServerControlImpl(); - try { - int server_command = server.parseArgs(new String[]{command}); + int server_command = server.parseArgs(new String[]{command}); - if (server_command == NetworkServerControlImpl.COMMAND_START) { - PrintWriter printWriter = new PrintWriter(out); - server.setLogWriter(printWriter); - server.start(printWriter); - } else if (server_command == NetworkServerControlImpl.COMMAND_SHUTDOWN) { - server.shutdown(); - } - - } catch (Exception e) { - // FIXME ... don't do this! - e.printStackTrace(); + if (server_command == NetworkServerControlImpl.COMMAND_START) { + PrintWriter printWriter = getOutput().getPrintWriter(); + server.setLogWriter(printWriter); + server.start(printWriter); + } else if (server_command == NetworkServerControlImpl.COMMAND_SHUTDOWN) { + server.shutdown(); } // server.executeWork(server_command); Modified: trunk/distr/src/apps/org/jnode/apps/edit/EditCommand.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/edit/EditCommand.java 2008-11-09 02:34:08 UTC (rev 4680) +++ trunk/distr/src/apps/org/jnode/apps/edit/EditCommand.java 2008-11-09 02:35:50 UTC (rev 4681) @@ -44,13 +44,13 @@ new EditCommand().execute(args); } - public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err) + public void execute() throws Exception { final File file = ARG_EDIT.isSet() ? ARG_EDIT.getValue() : null; if (file == null) Editor.editFile(null); else if (file.isDirectory()) { - err.println(file + " is a directory"); + getError().getPrintWriter().println(file + " is a directory"); } else { Editor.editFile(file); } Modified: trunk/distr/src/apps/org/jnode/apps/editor/LeedCommand.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/editor/LeedCommand.java 2008-11-09 02:34:08 UTC (rev 4680) +++ trunk/distr/src/apps/org/jnode/apps/editor/LeedCommand.java 2008-11-09 02:35:50 UTC (rev 4681) @@ -24,11 +24,11 @@ new LeedCommand().execute(args); } - public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err) + public void execute() throws Exception { final File file = ARG_EDIT.getValue(); if (file.isDirectory()) { - err.println(file + " is a directory"); + getError().getPrintWriter().println(file + " is a directory"); } else { TextEditor.main(new String[]{file.toString()}); } Modified: trunk/distr/src/apps/org/jnode/apps/editor/LeviCommand.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/editor/LeviCommand.java 2008-11-09 02:34:08 UTC (rev 4680) +++ trunk/distr/src/apps/org/jnode/apps/editor/LeviCommand.java 2008-11-09 02:35:50 UTC (rev 4681) @@ -27,11 +27,11 @@ new LeedCommand().execute(args); } - public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err) + public void execute() throws Exception { final File file = ARG_EDIT.getValue(); if (file.isDirectory()) { - System.err.println(file + " is a directory"); + getError().getPrintWriter().println(file + " is a directory"); } else { TextEditor.main(new String[]{file.toString(), "ro"}); } Modified: trunk/distr/src/apps/org/jnode/apps/httpd/NanoHTTPDCommand.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/httpd/NanoHTTPDCommand.java 2008-11-09 02:34:08 UTC (rev 4680) +++ trunk/distr/src/apps/org/jnode/apps/httpd/NanoHTTPDCommand.java 2008-11-09 02:35:50 UTC (rev 4681) @@ -37,7 +37,7 @@ public class NanoHTTPDCommand extends AbstractCommand { @Override - public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err) throws Exception { + public void execute() throws Exception { File file = new File("/jnode/index.htm"); // ram disk is fat, so no long extension, I guess if (!file.exists()) { @@ -59,7 +59,7 @@ try { Thread.sleep(250); } catch (InterruptedException e) { - e.printStackTrace(err); + e.printStackTrace(getError().getPrintWriter()); } } Modified: trunk/distr/src/apps/org/jnode/apps/jetty/JettyCommand.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/jetty/JettyCommand.java 2008-11-09 02:34:08 UTC (rev 4680) +++ trunk/distr/src/apps/org/jnode/apps/jetty/JettyCommand.java 2008-11-09 02:35:50 UTC (rev 4681) @@ -36,7 +36,7 @@ new JettyCommand().execute(args); } - public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err) + public void execute() throws Exception { File webapp_dir = ARG_WEBAPP.getValue(); int port = ARG_PORT.isSet() ? ARG_PORT.getValue() : 8080; Modified: trunk/distr/src/apps/org/jnode/apps/jpartition/JPartitionCommand.java =================================================================== --- trunk/distr/src/apps/org/jnode/apps/jpartition/JPartitionCommand.java 2008-11-09 02:34:08 UTC (rev 4680) +++ trunk/distr/src/apps/org/jnode/apps/jpartition/JPartitionCommand.java 2008-11-09 02:35:50 UTC (rev 4681) @@ -29,10 +29,12 @@ new JPartitionCommand().execute(args); } - public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err) - throws Exception { + public void execute() throws Exception { boolean install = ARG_INSTALL.isSet(); + InputStream in = getInput().getInputStream(); + PrintStream out = getOutput().getPrintStream(); + PrintStream err = getError().getPrintStream(); ViewFactory viewFactory = FLAG_CONSOLE.isSet() ? new ConsoleViewFactory(in, out, err) : FLAG_SWING.isSet() ? new SwingViewFactory() : null; Modified: trunk/fs/src/driver/org/jnode/driver/block/ramdisk/command/RamDiskCommand.java =================================================================== --- trunk/fs/src/driver/org/jnode/driver/block/ramdisk/command/RamDiskCommand.java 2008-11-09 02:34:08 UTC (rev 4680) +++ trunk/fs/src/driver/org/jnode/driver/block/ramdisk/command/RamDiskCommand.java 2008-11-09 02:35:50 UTC (rev 4681) @@ -54,8 +54,7 @@ new RamDiskCommand().execute(args); } - public void execute(CommandLine commandLine, InputStream in, - PrintStream out, PrintStream err) + public void execute() throws NameNotFoundException, DriverException, DeviceAlreadyRegisteredException { final DeviceManager dm = InitialNaming.lookup(DeviceManager.NAME); if (FLAG_CREATE.isSet()) { Modified: trunk/fs/src/fs/org/jnode/fs/command/AbstractFormatCommand.java =================================================================== --- trunk/fs/src/fs/org/jnode/fs/command/AbstractFormatCommand.java 2008-11-09 02:34:08 UTC (rev 4680) +++ trunk/fs/src/fs/org/jnode/fs/command/AbstractFormatCommand.java 2008-11-09 02:35:50 UTC (rev 4681) @@ -56,7 +56,7 @@ protected abstract Formatter<T> getFormatter(); - public final void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err) + public final void execute() throws FileSystemException, NameNotFoundException, DeviceNotFoundException, DriverException { Device dev = ARG_DEVICE.getValue(); Formatter<T> formatter = getFormatter(); Modified: trunk/gui/src/driver/org/jnode/driver/sound/command/BeepCommand.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/sound/command/BeepCommand.java 2008-11-09 02:34:08 UTC (rev 4680) +++ trunk/gui/src/driver/org/jnode/driver/sound/command/BeepCommand.java 2008-11-09 02:35:50 UTC (rev 4681) @@ -43,7 +43,7 @@ new BeepCommand().execute(args); } - public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err) { + public void execute() { SpeakerUtils.beep(); } } Modified: trunk/gui/src/driver/org/jnode/driver/sound/command/PlayCommand.java =================================================================== --- trunk/gui/src/driver/org/jnode/driver/sound/command/PlayCommand.java 2008-11-09 02:34:08 UTC (rev 4680) +++ trunk/gui/src/driver/org/jnode/driver/sound/command/PlayCommand.java 2008-11-09 02:35:50 UTC (rev 4681) @@ -70,7 +70,7 @@ new PlayCommand().execute(args); } - public void execute(CommandLine commandLine, InputStream in, PrintStream out, PrintStream err) { + public void execute() { Note[] tune = ARG_TUNE.isSet() ? ARG_TUNE.getValue() : SpeakerUtils.SCALE; SpeakerUtils.play(tune); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |