Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 26519 invoked from network); 27 Sep 2008 22:19:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 27 Sep 2008 22:19:26 -0000 Received: (qmail 16168 invoked by uid 500); 27 Sep 2008 22:19:24 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 16158 invoked by uid 500); 27 Sep 2008 22:19:24 -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 16149 invoked by uid 99); 27 Sep 2008 22:19:24 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 27 Sep 2008 15:19:24 -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; Sat, 27 Sep 2008 22:18:31 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id BC11623888A3; Sat, 27 Sep 2008 15:18:35 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r699749 - in /geronimo/gshell/trunk: gshell-commands/gshell-builtins/src/main/resources/META-INF/spring/ gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/ gshell-wisdom/gshell-wisdom-core/src/main/jav... Date: Sat, 27 Sep 2008 22:18:35 -0000 To: scm@geronimo.apache.org From: jdillon@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080927221835.BC11623888A3@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: jdillon Date: Sat Sep 27 15:18:35 2008 New Revision: 699749 URL: http://svn.apache.org/viewvc?rev=699749&view=rev Log: Added support for commands, which are basically limited aliases, but have full completer support (and show up as commands not aliases) Added: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/LinkCommand.java (contents, props changed) - copied, changed from r699743, geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/StatelessCommand.java Modified: geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/resources/META-INF/spring/components.xml geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/StatelessCommand.java geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/config/PluginParser.java geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/org/apache/geronimo/gshell/wisdom/config/wisdom-gshell.xsd 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-commands/gshell-builtins/src/main/resources/META-INF/spring/components.xml URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/resources/META-INF/spring/components.xml?rev=699749&r1=699748&r2=699749&view=diff ============================================================================== --- geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/resources/META-INF/spring/components.xml (original) +++ geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/resources/META-INF/spring/components.xml Sat Sep 27 15:18:35 2008 @@ -79,8 +79,8 @@ - - + + Copied: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/LinkCommand.java (from r699743, geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/StatelessCommand.java) URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/LinkCommand.java?p2=geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/LinkCommand.java&p1=geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/StatelessCommand.java&r1=699743&r2=699749&rev=699749&view=diff ============================================================================== --- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/StatelessCommand.java (original) +++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/LinkCommand.java Sat Sep 27 15:18:35 2008 @@ -19,40 +19,92 @@ package org.apache.geronimo.gshell.wisdom.command; +import org.apache.geronimo.gshell.command.Command; import org.apache.geronimo.gshell.command.CommandAction; import org.apache.geronimo.gshell.command.CommandCompleter; import org.apache.geronimo.gshell.command.CommandDocumenter; import org.apache.geronimo.gshell.i18n.MessageSource; -import org.apache.geronimo.gshell.spring.BeanContainerAware; +import org.apache.geronimo.gshell.registry.CommandRegistry; +import org.apache.geronimo.gshell.registry.NoSuchCommandException; +import org.springframework.beans.factory.annotation.Autowired; + +import java.io.PrintWriter; /** - * Stateless {@link org.apache.geronimo.gshell.command.Command} component. + * Link {@link Command} component. + * + * Link is similar to alias in concept, but only targets a named command, then re-uses all of that commands components. * * @version $Rev$ $Date$ */ -public class StatelessCommand +public class LinkCommand extends CommandSupport - implements BeanContainerAware { - // Expose some of our super-classes properties for spring configuration + @Autowired + private CommandRegistry commandRegistry; + + private String target; + + private Command command; + + public LinkCommand(final String target) { + assert target != null; + + this.target = target; + } + + private Command getCommand() { + if (command == null) { + assert commandRegistry != null; + assert target != null; + + try { + command = commandRegistry.getCommand(target); + } + catch (NoSuchCommandException e) { + throw new RuntimeException("Link target command not found: " + target, e); + } + } + + return command; + } @Override - public void setAction(final CommandAction action) { - super.setAction(action); + public CommandAction getAction() { + return getCommand().getAction(); } @Override - public void setDocumenter(final CommandDocumenter documenter) { - super.setDocumenter(documenter); + public CommandDocumenter getDocumenter() { + final CommandDocumenter delegate = getCommand().getDocumenter(); + + return new CommandDocumenter() { + public String getName() { + return delegate.getName(); + } + + public String getDescription() { + // TODO: i18n + return "Link to: " + target; + } + + public void renderUsage(PrintWriter out) { + delegate.renderUsage(out); + } + + public void renderManual(PrintWriter out) { + delegate.renderManual(out); + } + }; } @Override - public void setCompleter(final CommandCompleter completer) { - super.setCompleter(completer); + public CommandCompleter getCompleter() { + return getCommand().getCompleter(); } @Override - public void setMessages(final MessageSource messages) { - super.setMessages(messages); + public MessageSource getMessages() { + return getCommand().getMessages(); } } \ No newline at end of file Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/LinkCommand.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/LinkCommand.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/LinkCommand.java ------------------------------------------------------------------------------ svn:mergeinfo = Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/LinkCommand.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/StatelessCommand.java URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/StatelessCommand.java?rev=699749&r1=699748&r2=699749&view=diff ============================================================================== --- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/StatelessCommand.java (original) +++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/StatelessCommand.java Sat Sep 27 15:18:35 2008 @@ -32,7 +32,6 @@ */ public class StatelessCommand extends CommandSupport - implements BeanContainerAware { // Expose some of our super-classes properties for spring configuration Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/config/PluginParser.java URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/config/PluginParser.java?rev=699749&r1=699748&r2=699749&view=diff ============================================================================== --- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/config/PluginParser.java (original) +++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/config/PluginParser.java Sat Sep 27 15:18:35 2008 @@ -20,6 +20,7 @@ package org.apache.geronimo.gshell.wisdom.config; import org.apache.geronimo.gshell.wisdom.plugin.bundle.CommandBundle; +import org.apache.geronimo.gshell.wisdom.command.LinkCommand; import org.apache.geronimo.gshell.application.plugin.Plugin; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -86,6 +87,10 @@ private static final String ALIASES = "aliases"; + private static final String LINK = "link"; + + private static final String TARGET = "target"; + @Override protected boolean shouldGenerateId() { return true; @@ -320,6 +325,8 @@ ManagedMap commands = new ManagedMap(); // noinspection unchecked commands.putAll(parseCommands(element)); + // noinspection unchecked + commands.putAll(parseLinks(element)); bundle.addPropertyValue(COMMANDS, commands); ManagedMap aliases = new ManagedMap(); @@ -413,6 +420,30 @@ } // + // + // + + private Map parseLinks(final Element element) { + assert element != null; + + log.trace("Parse links; element; {}", element); + + Map links = new LinkedHashMap(); + + List children = getChildElements(element, LINK); + + for (Element child : children) { + BeanDefinitionBuilder link = BeanDefinitionBuilder.rootBeanDefinition(LinkCommand.class); + link.addConstructorArgValue(child.getAttribute(TARGET)); + + String name = child.getAttribute(NAME); + links.put(name, link.getBeanDefinition()); + } + + return links; + } + + // // // Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/org/apache/geronimo/gshell/wisdom/config/wisdom-gshell.xsd URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/org/apache/geronimo/gshell/wisdom/config/wisdom-gshell.xsd?rev=699749&r1=699748&r2=699749&view=diff ============================================================================== --- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/org/apache/geronimo/gshell/wisdom/config/wisdom-gshell.xsd (original) +++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/org/apache/geronimo/gshell/wisdom/config/wisdom-gshell.xsd Sat Sep 27 15:18:35 2008 @@ -62,6 +62,7 @@ + @@ -104,6 +105,21 @@ + + + + + Defines a link command. + + + + + + + + + + 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=699749&r1=699748&r2=699749&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 Sat Sep 27 15:18:35 2008 @@ -49,6 +49,8 @@ + +