Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 75036 invoked from network); 25 Sep 2008 18:03:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 25 Sep 2008 18:03:36 -0000 Received: (qmail 41988 invoked by uid 500); 25 Sep 2008 18:03:33 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 41928 invoked by uid 500); 25 Sep 2008 18:03:33 -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 41919 invoked by uid 99); 25 Sep 2008 18:03:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Sep 2008 11:03:33 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Sep 2008 18:02:41 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id C18502388961; Thu, 25 Sep 2008 11:02:44 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r699035 - in /geronimo/gshell/trunk: gshell-api/src/main/java/org/apache/geronimo/gshell/command/ gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/ gshell-wisdom/gshell-wisdom-core/src/main/java/org... Date: Thu, 25 Sep 2008 18:02:44 -0000 To: scm@geronimo.apache.org From: jdillon@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080925180244.C18502388961@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jdillon Date: Thu Sep 25 11:02:43 2008 New Revision: 699035 URL: http://svn.apache.org/viewvc?rev=699035&view=rev Log: Got basic alias muck working (not unalias yet), so you can: alias hi "echo hello" and then run: hi, help and help hi work, though hi --help is still broken Added: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/NullCommandCompleter.java (contents, props changed) - copied, changed from r698866, geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandCompleterImpl.java Removed: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandCompleterImpl.java Modified: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandAction.java geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/AliasAction.java geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/alias/AliasCommand.java geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/alias/AliasManagerImpl.java geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterSupport.java geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandSupport.java geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/spring/components.xml geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/resources/org/apache/geronimo/gshell/wisdom/config/PluginParserTest-context.xml Modified: geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandAction.java URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandAction.java?rev=699035&r1=699034&r2=699035&view=diff ============================================================================== --- geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandAction.java (original) +++ geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandAction.java Thu Sep 25 11:02:43 2008 @@ -37,7 +37,7 @@ * @throws Notification Inform the shell of some non-exception exit state. * @throws Exception Command execution failed. */ - Object execute(CommandContext context) throws Notification, Exception; + Object execute(CommandContext context) throws Exception; /** * Enumeration for the basic return types of a command execution. Modified: geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/AliasAction.java URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/AliasAction.java?rev=699035&r1=699034&r2=699035&view=diff ============================================================================== --- geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/AliasAction.java (original) +++ geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/AliasAction.java Thu Sep 25 11:02:43 2008 @@ -62,7 +62,7 @@ Collection aliases = aliasManager.getAliases(); if (aliases.isEmpty()) { - io.verbose("No aliases have been defined"); + io.info("No aliases have been defined"); } else { io.info("Defined aliases:"); Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/alias/AliasCommand.java URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/alias/AliasCommand.java?rev=699035&r1=699034&r2=699035&view=diff ============================================================================== --- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/alias/AliasCommand.java (original) +++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/alias/AliasCommand.java Thu Sep 25 11:02:43 2008 @@ -19,14 +19,17 @@ package org.apache.geronimo.gshell.wisdom.alias; -import jline.Completor; import org.apache.geronimo.gshell.command.CommandAction; -import org.apache.geronimo.gshell.command.CommandCompleter; import org.apache.geronimo.gshell.command.CommandContext; +import org.apache.geronimo.gshell.command.Variables; import org.apache.geronimo.gshell.i18n.MessageSource; -import org.apache.geronimo.gshell.notification.Notification; import org.apache.geronimo.gshell.wisdom.command.CommandDocumenterSupport; import org.apache.geronimo.gshell.wisdom.command.CommandSupport; +import org.apache.geronimo.gshell.wisdom.command.NullCommandCompleter; +import org.apache.geronimo.gshell.commandline.CommandLineExecutor; +import org.apache.geronimo.gshell.shell.ShellContext; +import org.apache.geronimo.gshell.io.IO; +import org.springframework.beans.factory.annotation.Autowired; /** * Alias {@link org.apache.geronimo.gshell.command.Command} component. @@ -36,6 +39,9 @@ public class AliasCommand extends CommandSupport { + @Autowired + private CommandLineExecutor executor; + private String name; private String target; @@ -49,41 +55,71 @@ setAction(new AliasCommandAction()); setDocumenter(new AliasCommandDocumenter()); - setCompleter(new AliasCommandCompleter()); + setCompleter(new NullCommandCompleter()); setMessages(new AliasCommandMessageSource()); } + public AliasCommand(final String name, final String target, final CommandLineExecutor executor) { + this(name, target); + + assert executor != null; + + this.executor = executor; + } + private class AliasCommandAction implements CommandAction { - public Object execute(final CommandContext context) throws Notification, Exception { - return null; + public Object execute(final CommandContext context) throws Exception { + assert context != null; + + // + // TODO: Take the args in the context, append them to target and execute the command via a shell, for now ignore args + // + + ShellContext shellContext = new ShellContext() { + public IO getIo() { + return context.getIo(); + } + + public Variables getVariables() { + return context.getVariables(); + } + }; + + log.debug("Executing alias target: {}", target); + + Object result = executor.execute(shellContext, target); + + log.debug("Alias result: {}", result); + + return result; } } + // + // TODO: May be able to stuff all of these into messages, since they are mostly the same for everything + // + private class AliasCommandDocumenter extends CommandDocumenterSupport { public String getName() { - return null; + return name; } public String getDescription() { - return null; + return "Alias to: " + target; } protected String getManual() { - return null; + return "TODO: general alias manual"; } } - private class AliasCommandCompleter - implements CommandCompleter - { - public Completor createCompletor() { - return null; - } - } + // + // NOTE: This is still needed for syntax rendering and such + // private class AliasCommandMessageSource implements MessageSource Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/alias/AliasManagerImpl.java URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/alias/AliasManagerImpl.java?rev=699035&r1=699034&r2=699035&view=diff ============================================================================== --- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/alias/AliasManagerImpl.java (original) +++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/alias/AliasManagerImpl.java Thu Sep 25 11:02:43 2008 @@ -22,7 +22,11 @@ import org.apache.geronimo.gshell.alias.Alias; import org.apache.geronimo.gshell.alias.AliasManager; import org.apache.geronimo.gshell.command.CommandRegistry; +import org.apache.geronimo.gshell.command.Command; import org.apache.geronimo.gshell.event.EventPublisher; +import org.apache.geronimo.gshell.commandline.CommandLineExecutor; +import org.apache.geronimo.gshell.spring.BeanContainerAware; +import org.apache.geronimo.gshell.spring.BeanContainer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -38,7 +42,7 @@ * @version $Rev$ $Date$ */ public class AliasManagerImpl - implements AliasManager + implements AliasManager, BeanContainerAware { private final Logger log = LoggerFactory.getLogger(getClass()); @@ -48,8 +52,19 @@ @Autowired private EventPublisher eventPublisher; + @Autowired + private CommandLineExecutor executor; + + private BeanContainer container; + private Map aliases = new LinkedHashMap(); + public void setBeanContainer(final BeanContainer container) { + assert container != null; + + this.container = container; + } + public Collection getAliases() { return Collections.unmodifiableCollection(aliases.values()); } @@ -65,7 +80,13 @@ log.debug("Defining alias: {} -> {}", name, target); - final AliasCommand command = new AliasCommand(name, target); + final AliasCommand command = new AliasCommand(name, target, executor); + + // + // FIXME: Have to inject the container because we are not wiring ^^^, and because its support muck needs some crap + // probably need to use a prototype here + // + command.setBeanContainer(container); Alias alias = new Alias() { public String getName() { @@ -76,12 +97,14 @@ return target; } - // TODO: Track the command + public Command getCommand() { + return command; + } }; aliases.put(name, alias); - // TODO: Register AliasCommand + commandRegistry.register(command); eventPublisher.publish(new AliasDefinedEvent(alias)); Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterSupport.java URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterSupport.java?rev=699035&r1=699034&r2=699035&view=diff ============================================================================== --- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterSupport.java (original) +++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterSupport.java Thu Sep 25 11:02:43 2008 @@ -45,8 +45,6 @@ private Command command; - private Renderer renderer = new Renderer(); - protected abstract String getManual(); // @@ -98,6 +96,8 @@ log.debug("Rendering command manual"); + Renderer renderer = new Renderer(); + out.println(renderer.render(Renderer.encode("NAME", Code.BOLD))); out.print(" "); out.println(getName()); Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandSupport.java URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandSupport.java?rev=699035&r1=699034&r2=699035&view=diff ============================================================================== --- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandSupport.java (original) +++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandSupport.java Thu Sep 25 11:02:43 2008 @@ -162,6 +162,10 @@ log.trace("Executing"); + // + // FIXME: This TCL stuff is not needed for alias execution, so consider splitting thigns up a wee bit more + // + // Set the TCL to the command bean containers realm final ClassLoader prevCL = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(getContainer().getClassRealm()); Copied: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/NullCommandCompleter.java (from r698866, geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandCompleterImpl.java) URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/NullCommandCompleter.java?p2=geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/NullCommandCompleter.java&p1=geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandCompleterImpl.java&r1=698866&r2=699035&rev=699035&view=diff ============================================================================== --- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandCompleterImpl.java (original) +++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/NullCommandCompleter.java Thu Sep 25 11:02:43 2008 @@ -21,22 +21,18 @@ import jline.Completor; import org.apache.geronimo.gshell.command.CommandCompleter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** - * The default {@link CommandCompleter} component. + * A null {@link CommandCompleter}. * * @version $Rev$ $Date$ */ -public class CommandCompleterImpl +public class NullCommandCompleter implements CommandCompleter { - private final Logger log = LoggerFactory.getLogger(getClass()); - public Completor createCompletor() { - // TODO: + // Nothing - throw new Error("Not implemented"); + return null; } } \ No newline at end of file Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/NullCommandCompleter.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/NullCommandCompleter.java ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/NullCommandCompleter.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/spring/components.xml URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/spring/components.xml?rev=699035&r1=699034&r2=699035&view=diff ============================================================================== --- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/spring/components.xml (original) +++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/spring/components.xml Thu Sep 25 11:02:43 2008 @@ -47,7 +47,7 @@ - + @@ -61,7 +61,7 @@ - + Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/resources/org/apache/geronimo/gshell/wisdom/config/PluginParserTest-context.xml URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/resources/org/apache/geronimo/gshell/wisdom/config/PluginParserTest-context.xml?rev=699035&r1=699034&r2=699035&view=diff ============================================================================== --- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/resources/org/apache/geronimo/gshell/wisdom/config/PluginParserTest-context.xml (original) +++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/test/resources/org/apache/geronimo/gshell/wisdom/config/PluginParserTest-context.xml Thu Sep 25 11:02:43 2008 @@ -50,7 +50,7 @@ - +