Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 71740 invoked from network); 31 May 2006 05:33:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 31 May 2006 05:33:56 -0000 Received: (qmail 17562 invoked by uid 500); 31 May 2006 05:33:56 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 17488 invoked by uid 500); 31 May 2006 05:33:55 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 17469 invoked by uid 99); 31 May 2006 05:33:55 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 May 2006 22:33:55 -0700 X-ASF-Spam-Status: No, hits=-8.6 required=10.0 tests=ALL_TRUSTED,INFO_TLD,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 May 2006 22:33:51 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 6FD291A983A; Tue, 30 May 2006 22:33:31 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r410434 - in /geronimo/sandbox/gshell/trunk: gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/ gshell-commands/scripting-commands/src/main/java/org/apache/geronimo/gshell/commands/scripting/ gshell-commands/standard-commands/src/main... Date: Wed, 31 May 2006 05:33:27 -0000 To: scm@geronimo.apache.org From: jdillon@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060531053331.6FD291A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: jdillon Date: Tue May 30 22:33:26 2006 New Revision: 410434 URL: http://svn.apache.org/viewvc?rev=410434&view=rev Log: Making use of Java 1.5 awesomeness to simplify code Added support to allow 'help' command to work again; still need to figure out how to use IoC with Command (that is really light) Isolated interactive bits for GShell into InteractiveGShell (moved from Main) Added some exceptions to provide better error handling for dealing with commands Added: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/InteractiveGShell.java (with props) geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandException.java (with props) geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandInstantiationException.java (with props) geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandNotFoundException.java (with props) geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/GShellTest.java (with props) geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/command/CommandManagerTest.java (with props) Modified: geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java geronimo/sandbox/gshell/trunk/gshell-commands/scripting-commands/src/main/java/org/apache/geronimo/gshell/commands/scripting/ScriptCommand.java geronimo/sandbox/gshell/trunk/gshell-commands/standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/EchoCommand.java geronimo/sandbox/gshell/trunk/gshell-commands/standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/HelpCommand.java geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/GShell.java geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/Command.java geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandContext.java geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandExecutor.java geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandManager.java geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/CommandLineBuilder.java geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/ExecutingVisitor.java geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/LoggingVisitor.java geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/command/MockCommandExecutor.java geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/commandline/parser/CommandLineParserVisitorTest.java 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=410434&r1=410433&r2=410434&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 Tue May 30 22:33:26 2006 @@ -29,9 +29,8 @@ import org.apache.commons.logging.LogFactory; import org.apache.geronimo.gshell.GShell; +import org.apache.geronimo.gshell.InteractiveGShell; import org.apache.geronimo.gshell.console.IO; -import org.apache.geronimo.gshell.console.InteractiveConsole; -import org.apache.geronimo.gshell.console.JLineConsole; import org.apache.geronimo.gshell.util.Version; import org.apache.geronimo.gshell.util.Banner; @@ -230,40 +229,14 @@ } if (interactive) { - // - // TODO: May want to create a simple class in core to hide these details - // - - InteractiveConsole console = new InteractiveConsole( - new JLineConsole(io), - new InteractiveConsole.Executor() { - public Result execute(final String line) throws Exception { - assert line != null; - - // Execute unless the line is just blank - if (!line.trim().equals("")) { - gshell.execute(line); - } - - return Result.CONTINUE; - } - }, - new InteractiveConsole.Prompter() { - public String getPrompt() { - // - // TODO: Need to hook this up to allow it to change - // - - return "> "; - } - }); + InteractiveGShell interp = new InteractiveGShell(io, gshell); // Check if there are args, and run them and then enter interactive if (args.length != 0) { gshell.execute(args); } - console.run(); + interp.run(); } else { int status = gshell.execute(args); Modified: geronimo/sandbox/gshell/trunk/gshell-commands/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/scripting-commands/src/main/java/org/apache/geronimo/gshell/commands/scripting/ScriptCommand.java?rev=410434&r1=410433&r2=410434&view=diff ============================================================================== --- geronimo/sandbox/gshell/trunk/gshell-commands/scripting-commands/src/main/java/org/apache/geronimo/gshell/commands/scripting/ScriptCommand.java (original) +++ geronimo/sandbox/gshell/trunk/gshell-commands/scripting-commands/src/main/java/org/apache/geronimo/gshell/commands/scripting/ScriptCommand.java Tue May 30 22:33:26 2006 @@ -146,7 +146,8 @@ } if (this.interactive) { - InteractiveInterpreter interp = new InteractiveInterpreter(new JLineConsole(getIO()), engine, language); + InteractiveInterpreter interp = new InteractiveInterpreter( + new JLineConsole(getIO()), engine, language); interp.run(); } Modified: geronimo/sandbox/gshell/trunk/gshell-commands/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/standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/EchoCommand.java?rev=410434&r1=410433&r2=410434&view=diff ============================================================================== --- geronimo/sandbox/gshell/trunk/gshell-commands/standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/EchoCommand.java (original) +++ geronimo/sandbox/gshell/trunk/gshell-commands/standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/EchoCommand.java Tue May 30 22:33:26 2006 @@ -94,9 +94,9 @@ private void echo(final String[] args) { IO io = getIO(); - - for (int i=0; i 1; Added: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/InteractiveGShell.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/InteractiveGShell.java?rev=410434&view=auto ============================================================================== --- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/InteractiveGShell.java (added) +++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/InteractiveGShell.java Tue May 30 22:33:26 2006 @@ -0,0 +1,59 @@ +/* + * Copyright 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.gshell; + +import org.apache.geronimo.gshell.console.InteractiveConsole; +import org.apache.geronimo.gshell.console.JLineConsole; +import org.apache.geronimo.gshell.console.IO; + +import java.io.IOException; + +/** + * ??? + * + * @version $Id$ + */ +public class InteractiveGShell + extends InteractiveConsole +{ + public InteractiveGShell(final IO io, final GShell gshell) throws IOException { + super(new JLineConsole(io), + + new InteractiveConsole.Executor() { + public Result execute(final String line) throws Exception { + assert line != null; + + // Execute unless the line is just blank + if (!line.trim().equals("")) { + gshell.execute(line); + } + + return Result.CONTINUE; + } + }, + + new InteractiveConsole.Prompter() { + public String getPrompt() { + // + // TODO: Need to hook this up to allow it to change + // + + return "> "; + } + }); + } +} Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/InteractiveGShell.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/InteractiveGShell.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/InteractiveGShell.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/Command.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/Command.java?rev=410434&r1=410433&r2=410434&view=diff ============================================================================== --- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/Command.java (original) +++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/Command.java Tue May 30 22:33:26 2006 @@ -37,7 +37,7 @@ // TODO: Return an Object! Take an Object[]! // - int execute(String[] args) throws Exception; + int execute(String... args) throws Exception; void abort(); // throws Exception ? Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandContext.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandContext.java?rev=410434&r1=410433&r2=410434&view=diff ============================================================================== --- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandContext.java (original) +++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandContext.java Tue May 30 22:33:26 2006 @@ -19,7 +19,7 @@ import org.apache.geronimo.gshell.console.IO; /** - * ??? + * Provides the running context (or environment) for a {@link Command}. * * @version $Id$ */ Added: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandException.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandException.java?rev=410434&view=auto ============================================================================== --- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandException.java (added) +++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandException.java Tue May 30 22:33:26 2006 @@ -0,0 +1,42 @@ +/* + * Copyright 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.gshell.command; + +/** + * A command exception. + * + * @version $Revision$ $Date$ + */ +public class CommandException + extends Exception +{ + public CommandException(String msg) { + super(msg); + } + + public CommandException(String msg, Throwable cause) { + super(msg, cause); + } + + public CommandException(Throwable cause) { + super(cause); + } + + public CommandException() { + super(); + } +} \ No newline at end of file Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandException.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandException.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandException.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandExecutor.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandExecutor.java?rev=410434&r1=410433&r2=410434&view=diff ============================================================================== --- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandExecutor.java (original) +++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandExecutor.java Tue May 30 22:33:26 2006 @@ -23,9 +23,7 @@ */ public interface CommandExecutor { - int execute(String commandline) throws Exception; - - int execute(String[] args) throws Exception; + int execute(String... args) throws Exception; int execute(String commandName, String[] args) throws Exception; } Added: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandInstantiationException.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandInstantiationException.java?rev=410434&view=auto ============================================================================== --- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandInstantiationException.java (added) +++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandInstantiationException.java Tue May 30 22:33:26 2006 @@ -0,0 +1,42 @@ +/* + * Copyright 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.gshell.command; + +/** + * Thrown to indicate a problem instantiating a command instance. + * + * @version $Revision$ $Date$ + */ +public class CommandInstantiationException + extends CommandException +{ + public CommandInstantiationException(final String msg) { + super(msg); + } + + public CommandInstantiationException(final String msg, final Throwable cause) { + super(msg, cause); + } + + public CommandInstantiationException(final Throwable cause) { + super(cause); + } + + public CommandInstantiationException() { + super(); + } +} Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandInstantiationException.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandInstantiationException.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandInstantiationException.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandManager.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandManager.java?rev=410434&r1=410433&r2=410434&view=diff ============================================================================== --- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandManager.java (original) +++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandManager.java Tue May 30 22:33:26 2006 @@ -18,11 +18,13 @@ import org.apache.xbean.finder.ResourceFinder; -import java.io.IOException; import java.util.Iterator; import java.util.Map; import java.util.Properties; import java.util.HashMap; +import java.util.List; +import java.util.Set; +import java.util.Collections; /** * ??? @@ -33,15 +35,22 @@ { private Map commandDefMap = new HashMap(); - public CommandManager() throws IOException { - ResourceFinder resourceFinder = new ResourceFinder("META-INF/"); + public CommandManager() throws CommandException { + try { + discoverCommands(); + } + catch (Exception e) { + throw new CommandException(e); + } + } - Map propertiesMap = resourceFinder.mapAllProperties("org.apache.geronimo.gshell.command"); - Iterator iter = propertiesMap.keySet().iterator(); + private void discoverCommands() throws Exception { + ResourceFinder finder = new ResourceFinder("META-INF/"); + Map map = finder.mapAllProperties("org.apache.geronimo.gshell.command"); + Iterator iter = map.keySet().iterator(); - while (iter.hasNext()) { - String filename = iter.next(); - Properties props = propertiesMap.get(filename); + for (String filename : map.keySet()) { + Properties props = map.get(filename); String name = props.getProperty("name"); if (name != null) { @@ -50,14 +59,40 @@ } } - public Command getCommand(final String name) throws ClassNotFoundException, IllegalAccessException, InstantiationException { - assert name != null; + public Command getCommand(final String name) throws CommandNotFoundException, CommandInstantiationException { + if (name == null) { + throw new IllegalArgumentException("Name is null"); + } + if (name.trim().length() == 0) { + throw new IllegalArgumentException("Name is empty"); + } Properties props = commandDefMap.get(name); - ClassLoader cl = Thread.currentThread().getContextClassLoader(); - Class type = cl.loadClass(props.getProperty("class")); - Command cmd = (Command)type.newInstance(); + + // No props means command was not discovered + if (props == null) { + throw new CommandNotFoundException(name); + } + + String classname = props.getProperty("class"); + if (classname == null) { + throw new CommandInstantiationException("Missing 'class' property for command: " + name); + } + + Command cmd; + try { + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + Class type = cl.loadClass(classname); + cmd = (Command)type.newInstance(); + } + catch (Exception e) { + throw new CommandInstantiationException(name, e); + } return cmd; + } + + public Set commandNames() { + return Collections.unmodifiableSet(commandDefMap.keySet()); } } Added: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandNotFoundException.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandNotFoundException.java?rev=410434&view=auto ============================================================================== --- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandNotFoundException.java (added) +++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandNotFoundException.java Tue May 30 22:33:26 2006 @@ -0,0 +1,35 @@ +/* + * Copyright 2006 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.gshell.command; + +/** + * Thrown to indicate that an operation which requires a named + * command has failed because the command was not found. + * + * @version $Revision$ $Date$ + */ +public class CommandNotFoundException + extends CommandException +{ + public CommandNotFoundException(final String path) { + this(path, "Command or path was not found"); + } + + public CommandNotFoundException(final String path, final String msg) { + super(msg + ": " + path); + } +} \ No newline at end of file Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandNotFoundException.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandNotFoundException.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandNotFoundException.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java?rev=410434&r1=410433&r2=410434&view=diff ============================================================================== --- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java (original) +++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java Tue May 30 22:33:26 2006 @@ -132,7 +132,7 @@ // Execute Helpers // - public int execute(final String[] args) throws Exception { + public int execute(final String... args) throws Exception { assert args != null; // Make sure that we have been initialized before we go any further @@ -146,6 +146,10 @@ status = doExecute(args); } catch (Exception e) { + // + // TODO: Handle Errors here too + // + log.error(e.getMessage()); if (log.isDebugEnabled()) { log.debug("Failure details", e); Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/CommandLineBuilder.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/CommandLineBuilder.java?rev=410434&r1=410433&r2=410434&view=diff ============================================================================== --- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/CommandLineBuilder.java (original) +++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/CommandLineBuilder.java Tue May 30 22:33:26 2006 @@ -35,9 +35,9 @@ { private static final Log log = LogFactory.getLog(CommandLineBuilder.class); - private CommandExecutor executor; + private final CommandExecutor executor; - private CommandLineParser parser; + private final CommandLineParser parser; public CommandLineBuilder(final CommandExecutor executor) { if (executor == null) { 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=410434&r1=410433&r2=410434&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 Tue May 30 22:33:26 2006 @@ -43,7 +43,7 @@ { private static final Log log = LogFactory.getLog(ExecutingVisitor.class); - private CommandExecutor executor; + private final CommandExecutor executor; public ExecutingVisitor(final CommandExecutor executor) { if (executor == null) { Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/LoggingVisitor.java URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/LoggingVisitor.java?rev=410434&r1=410433&r2=410434&view=diff ============================================================================== --- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/LoggingVisitor.java (original) +++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/LoggingVisitor.java Tue May 30 22:33:26 2006 @@ -26,6 +26,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.commons.lang.StringUtils; /** * Visitor whichs logs nodes in the tree. @@ -35,8 +36,15 @@ public class LoggingVisitor implements CommandLineParserVisitor { + public static enum Level { + INFO, + DEBUG + } + private final Log log; + private final Level level; + private int indent = 0; public LoggingVisitor() { @@ -44,20 +52,39 @@ } public LoggingVisitor(final Log log) { + this(log, Level.DEBUG); + } + + public LoggingVisitor(final Log log, final Level level) { if (log == null) { throw new IllegalArgumentException("Log is null"); } + if (level == null) { + throw new IllegalArgumentException("Level is null"); + } this.log = log; + this.level = level; } private Object log(final Class type, final SimpleNode node, Object data) { - if (!log.isDebugEnabled()) { - return data; + // Short-circuit of logging level does not match + switch (level) { + case INFO: + if (!log.isInfoEnabled()) { + return data; + } + break; + + case DEBUG: + if (!log.isDebugEnabled()) { + return data; + } + break; } StringBuffer buff = new StringBuffer(); - + for (int i=0; i