You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2008/09/26 09:04:00 UTC
svn commit: r699196 - in /geronimo/gshell/trunk:
gshell-api/src/main/java/org/apache/geronimo/gshell/command/
gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/alias/
gshell-wisdom/gshell-wisdom-core/src/main/java/org/apa...
Author: jdillon
Date: Fri Sep 26 00:03:59 2008
New Revision: 699196
URL: http://svn.apache.org/viewvc?rev=699196&view=rev
Log:
Tidy up
Added:
geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/MessageSourceCommandDocumenter.java (contents, props changed)
- copied, changed from r699021, geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterImpl.java
Removed:
geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterImpl.java
Modified:
geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandRegistry.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/command/CommandDocumenterSupport.java
geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/StatefulCommand.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/CommandRegistry.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandRegistry.java?rev=699196&r1=699195&r2=699196&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandRegistry.java (original)
+++ geronimo/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandRegistry.java Fri Sep 26 00:03:59 2008
@@ -30,5 +30,9 @@
{
CommandRegistration register(Command command);
+ // boolean isRegistered(String name);
+
+ // void unregister(String name);
+
Collection<CommandRegistration> getRegistrations();
}
\ No newline at end of file
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=699196&r1=699195&r2=699196&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 Fri Sep 26 00:03:59 2008
@@ -73,10 +73,6 @@
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();
@@ -87,9 +83,29 @@
}
};
- log.debug("Executing alias target: {}", target);
+ StringBuilder buff = new StringBuilder();
+ buff.append(target);
+
+ //
+ // FIXME: For this to work correctly, need to follow stateful command pattern
+ // and construct this action, or override more muck in CommandSupport
+ //
+
+ // Append arguments from the context to the line to execute quoted
+ Object[] args = context.getArguments();
+ for (int i=0; i<args.length; i++) {
+ buff.append("'");
+ buff.append(args[i]);
+ buff.append("'");
+ if (i+1 < args.length) {
+ buff.append(" ");
+ }
+ }
+
+ String line = buff.toString();
+ log.debug("Executing alias target: {}", line);
- Object result = executor.execute(shellContext, target);
+ Object result = executor.execute(shellContext, line);
log.debug("Alias result: {}", result);
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=699196&r1=699195&r2=699196&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 Fri Sep 26 00:03:59 2008
@@ -45,8 +45,6 @@
private Command command;
- protected abstract String getManual();
-
//
// CommandAware
//
@@ -70,7 +68,7 @@
public void renderUsage(final PrintWriter out) {
assert out != null;
- log.debug("Rendering command usage");
+ log.trace("Rendering command usage");
CommandLineProcessor clp = new CommandLineProcessor();
@@ -91,10 +89,12 @@
printer.printUsage(out, getName());
}
+ protected abstract String getManual();
+
public void renderManual(final PrintWriter out) {
assert out != null;
- log.debug("Rendering command manual");
+ log.trace("Rendering command manual");
Renderer renderer = new Renderer();
Copied: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/MessageSourceCommandDocumenter.java (from r699021, geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterImpl.java)
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/MessageSourceCommandDocumenter.java?p2=geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/MessageSourceCommandDocumenter.java&p1=geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterImpl.java&r1=699021&r2=699196&rev=699196&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterImpl.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/MessageSourceCommandDocumenter.java Fri Sep 26 00:03:59 2008
@@ -20,42 +20,37 @@
package org.apache.geronimo.gshell.wisdom.command;
import org.apache.geronimo.gshell.command.CommandDocumenter;
+import org.apache.geronimo.gshell.i18n.MessageSource;
/**
- * {@link CommandDocumenter} component.
+ * {@link MessageSource} {@link CommandDocumenter} component.
*
* @version $Rev$ $Date$
*/
-public class CommandDocumenterImpl
+public class MessageSourceCommandDocumenter
extends CommandDocumenterSupport
{
- private String name;
+ private static final String COMMAND_NAME = "command.name";
- private String description;
+ private static final String COMMAND_DESCRIPTION = "command.description";
- public String getName() {
- if (name == null) {
- name = getCommand().getMessages().getMessage("command.name");
- }
- return name;
- }
+ private static final String COMMAND_MANUAL = "command.manual";
- public void setName(final String name) {
- this.name = name;
+ protected MessageSource getMessages() {
+ MessageSource messages = getCommand().getMessages();
+ assert messages != null;
+ return messages;
}
- public String getDescription() {
- if (description == null) {
- description = getCommand().getMessages().getMessage("command.description");
- }
- return description;
+ public String getName() {
+ return getMessages().getMessage(COMMAND_NAME);
}
- public void setDescription(final String description) {
- this.description = description;
+ public String getDescription() {
+ return getMessages().getMessage(COMMAND_DESCRIPTION);
}
protected String getManual() {
- return getCommand().getMessages().getMessage("command.manual");
+ return getMessages().getMessage(COMMAND_MANUAL);
}
}
\ No newline at end of file
Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/MessageSourceCommandDocumenter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/MessageSourceCommandDocumenter.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/MessageSourceCommandDocumenter.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/StatefulCommand.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/StatefulCommand.java?rev=699196&r1=699195&r2=699196&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/StatefulCommand.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/StatefulCommand.java Fri Sep 26 00:03:59 2008
@@ -34,7 +34,7 @@
public class StatefulCommand
extends CommandSupport
{
- private InheritableThreadLocal<CommandAction> actionHolder = new InheritableThreadLocal<CommandAction>();
+ private final ThreadLocal<CommandAction> actionHolder = new ThreadLocal<CommandAction>();
private String actionId;
@@ -74,7 +74,7 @@
private synchronized CommandAction createAction() {
String id = getActionId();
- log.debug("Creating action for ID: {}", id);
+ log.trace("Creating action for ID: {}", id);
return getContainer().getBean(id, CommandAction.class);
}
@@ -82,7 +82,7 @@
private synchronized void clearAction() {
actionHolder.remove();
- log.debug("Action cleared");
+ log.trace("Action cleared");
}
@Override
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=699196&r1=699195&r2=699196&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 Fri Sep 26 00:03:59 2008
@@ -43,7 +43,7 @@
<bean id="statelessCommandTemplate" class="org.apache.geronimo.gshell.wisdom.command.StatelessCommand" abstract="true">
<property name="documenter">
- <bean class="org.apache.geronimo.gshell.wisdom.command.CommandDocumenterImpl"/>
+ <bean class="org.apache.geronimo.gshell.wisdom.command.MessageSourceCommandDocumenter"/>
</property>
<property name="completer">
@@ -57,7 +57,7 @@
<bean id="statefulCommandTemplate" class="org.apache.geronimo.gshell.wisdom.command.StatefulCommand" abstract="true">
<property name="documenter">
- <bean class="org.apache.geronimo.gshell.wisdom.command.CommandDocumenterImpl"/>
+ <bean class="org.apache.geronimo.gshell.wisdom.command.MessageSourceCommandDocumenter"/>
</property>
<property name="completer">
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=699196&r1=699195&r2=699196&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 Fri Sep 26 00:03:59 2008
@@ -49,7 +49,7 @@
<gshell:command name="e">
<gshell:action class="org.apache.geronimo.gshell.wisdom.config.DummyAction"/>
- <gshell:documenter class="org.apache.geronimo.gshell.wisdom.command.CommandDocumenterImpl"/>
+ <gshell:documenter class="org.apache.geronimo.gshell.wisdom.command.MessageSourceCommandDocumenter"/>
<gshell:completer class="org.apache.geronimo.gshell.wisdom.command.NullCommandCompleter"/>
<gshell:message-source class="org.apache.geronimo.gshell.wisdom.command.CommandMessageSource"/>
</gshell:command>