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 2007/09/06 20:20:56 UTC
svn commit: r573330 [1/2] - in /geronimo/sandbox/gshell/trunk: ./
gshell-ansi/src/main/resources/org/ gshell-ansi/src/site/
gshell-ansi/src/site/apt/
gshell-api/src/main/java/org/apache/geronimo/gshell/command/
gshell-api/src/main/java/org/apache/geron...
Author: jdillon
Date: Thu Sep 6 11:20:42 2007
New Revision: 573330
URL: http://svn.apache.org/viewvc?rev=573330&view=rev
Log:
Massive update refact-o-tron
Added:
geronimo/sandbox/gshell/trunk/gshell-ansi/src/site/
- copied from r572601, geronimo/sandbox/gshell/trunk/gshell-commands/src/site/
geronimo/sandbox/gshell/trunk/gshell-ansi/src/site/apt/
- copied from r573329, geronimo/sandbox/gshell/trunk/gshell-commands/src/site/apt/
geronimo/sandbox/gshell/trunk/gshell-ansi/src/site/site.xml
- copied unchanged from r573329, geronimo/sandbox/gshell/trunk/gshell-commands/src/site/site.xml
geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandContext.java
- copied, changed from r572601, geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Environment.java
geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/ShellInfo.java (with props)
geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/annotation/
geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/annotation/Command.java
- copied, changed from r572601, geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Command.java
geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/annotation/package-info.java (with props)
geronimo/sandbox/gshell/trunk/gshell-assembly/src/site/
- copied from r572601, geronimo/sandbox/gshell/trunk/gshell-commands/src/site/
geronimo/sandbox/gshell/trunk/gshell-assembly/src/site/apt/
- copied from r573329, geronimo/sandbox/gshell/trunk/gshell-commands/src/site/apt/
geronimo/sandbox/gshell/trunk/gshell-assembly/src/site/site.xml
- copied unchanged from r573329, geronimo/sandbox/gshell/trunk/gshell-commands/src/site/site.xml
geronimo/sandbox/gshell/trunk/gshell-bootstrap/src/site/
- copied from r572601, geronimo/sandbox/gshell/trunk/gshell-commands/src/site/
geronimo/sandbox/gshell/trunk/gshell-bootstrap/src/site/apt/
- copied from r573329, geronimo/sandbox/gshell/trunk/gshell-commands/src/site/apt/
geronimo/sandbox/gshell/trunk/gshell-bootstrap/src/site/site.xml
- copied unchanged from r573329, geronimo/sandbox/gshell/trunk/gshell-commands/src/site/site.xml
geronimo/sandbox/gshell/trunk/gshell-clp/src/site/
- copied from r572601, geronimo/sandbox/gshell/trunk/gshell-commands/src/site/
geronimo/sandbox/gshell/trunk/gshell-clp/src/site/apt/
- copied from r573329, geronimo/sandbox/gshell/trunk/gshell-commands/src/site/apt/
geronimo/sandbox/gshell/trunk/gshell-clp/src/site/site.xml
- copied unchanged from r573329, geronimo/sandbox/gshell/trunk/gshell-commands/src/site/site.xml
geronimo/sandbox/gshell/trunk/gshell-common/src/site/
- copied from r572601, geronimo/sandbox/gshell/trunk/gshell-commands/src/site/
geronimo/sandbox/gshell/trunk/gshell-common/src/site/apt/
- copied from r573329, geronimo/sandbox/gshell/trunk/gshell-commands/src/site/apt/
geronimo/sandbox/gshell/trunk/gshell-common/src/site/site.xml
- copied unchanged from r573329, geronimo/sandbox/gshell/trunk/gshell-commands/src/site/site.xml
geronimo/sandbox/gshell/trunk/gshell-console/src/site/
- copied from r572601, geronimo/sandbox/gshell/trunk/gshell-commands/src/site/
geronimo/sandbox/gshell/trunk/gshell-console/src/site/apt/
- copied from r573329, geronimo/sandbox/gshell/trunk/gshell-commands/src/site/apt/
geronimo/sandbox/gshell/trunk/gshell-console/src/site/site.xml
- copied unchanged from r573329, geronimo/sandbox/gshell/trunk/gshell-commands/src/site/site.xml
geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ShellImpl.java
- copied, changed from r572601, geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/Shell.java
geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ShellInfoImpl.java (contents, props changed)
- copied, changed from r572601, geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/EnvironmentImpl.java
geronimo/sandbox/gshell/trunk/gshell-core/src/main/resources/META-INF/plexus/
geronimo/sandbox/gshell/trunk/gshell-core/src/main/resources/META-INF/plexus/plexus.xml (with props)
geronimo/sandbox/gshell/trunk/gshell-diet/src/
- copied from r572601, geronimo/sandbox/gshell/trunk/gshell-commands/src/
geronimo/sandbox/gshell/trunk/gshell-diet/src/site/
- copied from r573329, geronimo/sandbox/gshell/trunk/gshell-commands/src/site/
geronimo/sandbox/gshell/trunk/gshell-i18n/src/site/
- copied from r572601, geronimo/sandbox/gshell/trunk/gshell-commands/src/site/
geronimo/sandbox/gshell/trunk/gshell-i18n/src/site/apt/
- copied from r573329, geronimo/sandbox/gshell/trunk/gshell-commands/src/site/apt/
geronimo/sandbox/gshell/trunk/gshell-i18n/src/site/site.xml
- copied unchanged from r573329, geronimo/sandbox/gshell/trunk/gshell-commands/src/site/site.xml
geronimo/sandbox/gshell/trunk/gshell-maven-plugin/
geronimo/sandbox/gshell/trunk/gshell-maven-plugin/LICENSE.txt (with props)
geronimo/sandbox/gshell/trunk/gshell-maven-plugin/NOTICE.txt (with props)
geronimo/sandbox/gshell/trunk/gshell-maven-plugin/pom.xml (with props)
geronimo/sandbox/gshell/trunk/gshell-maven-plugin/src/
geronimo/sandbox/gshell/trunk/gshell-maven-plugin/src/main/
geronimo/sandbox/gshell/trunk/gshell-maven-plugin/src/main/java/
geronimo/sandbox/gshell/trunk/gshell-maven-plugin/src/main/java/org/
geronimo/sandbox/gshell/trunk/gshell-maven-plugin/src/main/java/org/apache/
geronimo/sandbox/gshell/trunk/gshell-maven-plugin/src/main/java/org/apache/geronimo/
geronimo/sandbox/gshell/trunk/gshell-maven-plugin/src/main/java/org/apache/geronimo/gshell/
geronimo/sandbox/gshell/trunk/gshell-maven-plugin/src/main/java/org/apache/geronimo/gshell/maven/
geronimo/sandbox/gshell/trunk/gshell-maven-plugin/src/main/java/org/apache/geronimo/gshell/maven/gshell/
geronimo/sandbox/gshell/trunk/gshell-maven-plugin/src/main/java/org/apache/geronimo/gshell/maven/gshell/PluginDescriptorMojo.java (with props)
geronimo/sandbox/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/
geronimo/sandbox/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/CommandDescriptor.java (with props)
geronimo/sandbox/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/PluginCollector.java (contents, props changed)
- copied, changed from r572601, geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/GShellPluginCollector.java
geronimo/sandbox/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/PluginDescriptor.java (with props)
geronimo/sandbox/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/PluginDescriptorBuilder.java (with props)
geronimo/sandbox/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/PluginDiscoverer.java (contents, props changed)
- copied, changed from r572601, geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/GShellPluginDiscoverer.java
geronimo/sandbox/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/model/
geronimo/sandbox/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/model/package-info.java (with props)
geronimo/sandbox/gshell/trunk/gshell-plugin/src/main/java/org/apache/geronimo/gshell/plugin/package-info.java (with props)
geronimo/sandbox/gshell/trunk/gshell-prefs/src/site/
- copied from r572601, geronimo/sandbox/gshell/trunk/gshell-commands/src/site/
geronimo/sandbox/gshell/trunk/gshell-prefs/src/site/apt/
- copied from r573329, geronimo/sandbox/gshell/trunk/gshell-commands/src/site/apt/
geronimo/sandbox/gshell/trunk/gshell-prefs/src/site/site.xml
- copied unchanged from r573329, geronimo/sandbox/gshell/trunk/gshell-commands/src/site/site.xml
Removed:
geronimo/sandbox/gshell/trunk/gshell-ansi/src/main/resources/org/
geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Environment.java
geronimo/sandbox/gshell/trunk/gshell-api/src/main/resources/org/
geronimo/sandbox/gshell/trunk/gshell-commands/gshell-bsf/src/main/resources/META-INF/
geronimo/sandbox/gshell/trunk/gshell-commands/gshell-bsf/src/main/resources/org/
geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/src/main/resources/org/
geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/src/main/resources/META-INF/
geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/src/main/resources/org/
geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs/src/main/resources/META-INF/
geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs/src/main/resources/org/
geronimo/sandbox/gshell/trunk/gshell-common/src/main/resources/org/
geronimo/sandbox/gshell/trunk/gshell-console/src/main/resources/org/
geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/EnvironmentImpl.java
geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/GShellPluginCollector.java
geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/GShellPluginDiscoverer.java
geronimo/sandbox/gshell/trunk/gshell-core/src/main/resources/org/
geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/CommandLineBuilderTest.java
geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/ExecutingVisitorTest.java
geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/MockShell.java
geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/ShellTest.java
geronimo/sandbox/gshell/trunk/gshell-i18n/src/main/resources/org/
geronimo/sandbox/gshell/trunk/gshell-layout/src/main/resources/META-INF/
geronimo/sandbox/gshell/trunk/gshell-layout/src/main/resources/org/
geronimo/sandbox/gshell/trunk/gshell-parser/src/main/resources/META-INF/
geronimo/sandbox/gshell/trunk/gshell-plugin/src/main/resources/META-INF/
geronimo/sandbox/gshell/trunk/gshell-plugin/src/main/resources/org/
geronimo/sandbox/gshell/trunk/gshell-prefs/src/main/resources/org/
Modified:
geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Command.java
geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java
geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/IO.java
geronimo/sandbox/gshell/trunk/gshell-assembly/pom.xml
geronimo/sandbox/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Launcher.java
geronimo/sandbox/gshell/trunk/gshell-cli/src/main/resources/META-INF/plexus/plexus.xml
geronimo/sandbox/gshell/trunk/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/ArgumentDescriptor.java
geronimo/sandbox/gshell/trunk/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/OptionDescriptor.java
geronimo/sandbox/gshell/trunk/gshell-commands/gshell-bsf/pom.xml
geronimo/sandbox/gshell/trunk/gshell-commands/gshell-bsf/src/main/java/org/apache/geronimo/gshell/commands/bsf/ScriptCommand.java
geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/pom.xml
geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/ExitCommand.java
geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpCommand.java
geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/SetCommand.java
geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/SourceCommand.java
geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/UnsetCommand.java
geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/pom.xml
geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/CatCommand.java
geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/EchoCommand.java
geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/ExecuteCommand.java
geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/JavaCommand.java
geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/SleepCommand.java
geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/WaitCommand.java
geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs/pom.xml
geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyCommand.java
geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/VFSCommandSupport.java
geronimo/sandbox/gshell/trunk/gshell-common/src/main/java/org/apache/geronimo/gshell/common/StopWatch.java
geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/Shell.java
geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/VariablesImplTest.java
geronimo/sandbox/gshell/trunk/gshell-layout/src/main/java/org/apache/geronimo/gshell/layout/LayoutManagerImpl.java
geronimo/sandbox/gshell/trunk/gshell-layout/src/main/java/org/apache/geronimo/gshell/layout/model/Command.java
geronimo/sandbox/gshell/trunk/gshell-plugin/src/main/mdo/plugin.mdo
geronimo/sandbox/gshell/trunk/gshell-plugin/src/test/java/org/apache/geronimo/gshell/plugin/model/BasicModelValidationTest.java
geronimo/sandbox/gshell/trunk/gshell-plugin/src/test/resources/org/apache/geronimo/gshell/plugin/model/plugins1.xml
geronimo/sandbox/gshell/trunk/javacc-maven-plugin/pom.xml
geronimo/sandbox/gshell/trunk/pom.xml
Modified: geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Command.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Command.java?rev=573330&r1=573329&r2=573330&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Command.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Command.java Thu Sep 6 11:20:42 2007
@@ -20,21 +20,35 @@
package org.apache.geronimo.gshell.command;
/**
- * ???
+ * Provides the basic interface for commands.
*
* @version $Rev$ $Date$
*/
public interface Command
{
/** Standard command success status code. */
- int SUCCESS = 0;
+ Result SUCCESS = Result.SUCCESS;
/** Standard command failure status code. */
- int FAILURE = -1;
+ Result FAILURE = Result.FAILURE;
- void init(CommandContext context); // throws Exception ?
+ /**
+ * Initialize the command with its execution context.
+ */
+ void init(CommandContext context);
+ /**
+ * Execute the commands behavior.
+ */
Object execute(Object... args) throws Exception;
-
- void destroy(); // throws Exception ?
+
+ //
+ // Result
+ //
+
+ enum Result
+ {
+ SUCCESS,
+ FAILURE
+ }
}
Copied: geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandContext.java (from r572601, geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Environment.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandContext.java?p2=geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandContext.java&p1=geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Environment.java&r1=572601&r2=573330&rev=573330&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Environment.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandContext.java Thu Sep 6 11:20:42 2007
@@ -22,11 +22,20 @@
import java.io.File;
/**
- * Provides a general abstraction of the shell's current executing environment.
+ * Provides commands with the context of its execution.
*
* @version $Rev$ $Date$
*/
-public interface Environment
+public interface CommandContext
{
- File getHomeDir();
-}
+ IO getIO();
+
+ Variables getVariables();
+
+
+ //
+ // TODO: Split up the Shell's bits from the commands bits maybe? Or expose a ShellInfo object for these bits maybe?
+ //
+
+ // File getHomeDir();
+}
\ No newline at end of file
Modified: geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java?rev=573330&r1=573329&r2=573330&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java Thu Sep 6 11:20:42 2007
@@ -19,8 +19,6 @@
package org.apache.geronimo.gshell.command;
-import java.util.Iterator;
-
import org.apache.geronimo.gshell.clp.CommandLineProcessor;
import org.apache.geronimo.gshell.clp.Option;
import org.apache.geronimo.gshell.clp.Printer;
@@ -37,154 +35,29 @@
public abstract class CommandSupport
implements Command
{
- protected Logger log;
+ protected Logger log = LoggerFactory.getLogger(getClass());
+
+ protected CommandContext context;
- private CommandContext context;
+ protected IO io;
+ protected Variables variables;
+
@Option(name="-h", aliases={"--help"}, description="Display this help message")
private boolean displayHelp;
- protected CommandSupport() {
- super();
- }
-
- //
- // Life-cycle
- //
-
- private void dump(final Variables vars) {
- Iterator<String> iter = vars.names();
-
- if (iter.hasNext()) {
- log.debug("Variables:");
- }
-
- while (iter.hasNext()) {
- String name = iter.next();
-
- log.debug(" " + name + "=" + vars.get(name));
- }
- }
-
- public final void init(final CommandContext context) {
- if (this.context != null) {
- throw new IllegalStateException("Command already initalized");
- }
-
- //
- // FIXME: Need to get the descriptor from the env to get the bound name
- //
-
- // Initialize logging with command name
- // log = LoggerFactory.getLogger(this.getClass().getName() + "." + getName());
- log = LoggerFactory.getLogger(getClass());
-
- log.debug("Initializing");
+ public void init(final CommandContext context) {
+ assert context != null;
this.context = context;
-
- //
- // TODO: Add preference support
- //
-
- if (log.isDebugEnabled()) {
- dump(context.getVariables());
- }
-
- try {
- doInit();
- }
- catch (Exception e) {
- log.error("Initialization failed", e);
-
- //
- // HACK: Need to handle or descide to ignore this exception
- //
-
- throw new RuntimeException("Command initialization failed", e);
- }
-
- log.debug("Initialized");
- }
-
- protected void doInit() throws Exception {
- // Sub-class should override to provide custom initialization
- }
-
- private void ensureInitialized() {
- if (context == null) {
- throw new IllegalStateException("Command has not been initialized");
- }
- }
-
- public final void destroy() {
- if (this.context == null) {
- throw new IllegalStateException("Command already destroyed (or never initialized)");
- }
-
- log.debug("Destroying");
-
- if (log.isDebugEnabled()) {
- dump(context.getVariables());
- }
-
- try {
- doDestroy();
- }
- catch (Exception e) {
- log.error("Destruction failed", e);
-
- //
- // HACK: Need to handle or descide to ignore this exception
- //
-
- throw new RuntimeException("Command destruction failed", e);
- }
-
- this.context = null;
-
- log.debug("Destroyed");
- }
-
- protected void doDestroy() throws Exception {
- // Sub-class should override to provide custom cleanup
- }
-
- //
- // Context Helpers
- //
-
- protected CommandContext getCommandContext() {
- if (context == null) {
- throw new IllegalStateException("Not initialized; missing command context");
- }
-
- return context;
+ this.io = context.getIO();
+ this.variables = context.getVariables();
}
- protected Variables getVariables() {
- return getCommandContext().getVariables();
- }
-
- protected IO getIO() {
- return getCommandContext().getIO();
- }
-
- //
- // Execute Helpers
- //
-
public Object execute(final Object... args) throws Exception {
assert args != null;
- // Make sure that we have been initialized before we go any further
- ensureInitialized();
-
- boolean info = log.isInfoEnabled();
-
- if (info) {
- log.info("Executing w/arguments: " + Arguments.asString(args));
- }
+ log.info("Executing w/arguments: {}", Arguments.asString(args));
Object result = null;
@@ -226,14 +99,8 @@
result = Command.FAILURE;
}
- finally {
- // Be sure to flush the commands outputs
- getIO().flush();
- }
-
- if (info) {
- log.info("Command exited with result: " + result);
- }
+
+ log.info("Command exiting with result: {}", result);
return result;
}
@@ -247,15 +114,6 @@
// CLI Fluff
//
- /**
- * Returns the command-line usage.
- *
- * @return The command-line usage.
- */
- protected String getUsage() {
- return "[options]";
- }
-
//
// NOTE: I think this should probably just go the f away... The usage mucko oh top too... gotta either be able
// to generate that, or configure it via an annotation. For the help, well we can add some header/footer muck
@@ -265,12 +123,6 @@
protected void displayHelp(final CommandLineProcessor clp) {
assert clp != null;
-
- IO io = getIO();
-
- //
- // FIXME: Need to get the command name from the env
- //
// io.out.print(getName());
// io.out.print(" -- ");
Modified: geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/IO.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/IO.java?rev=573330&r1=573329&r2=573330&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/IO.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/IO.java Thu Sep 6 11:20:42 2007
@@ -186,4 +186,8 @@
VERBOSE,
DEBUG
}
+
+ //
+ // TODO: Add vararg-based helpers to make dealing with verbosity levels easier on developers
+ //
}
Added: geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/ShellInfo.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/ShellInfo.java?rev=573330&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/ShellInfo.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/ShellInfo.java Thu Sep 6 11:20:42 2007
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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;
+
+import java.io.File;
+
+/**
+ * Provides some runtime information about the shell.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ShellInfo
+{
+ File getHomeDir();
+}
\ No newline at end of file
Propchange: geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/ShellInfo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/ShellInfo.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/ShellInfo.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Copied: geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/annotation/Command.java (from r572601, geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Command.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/annotation/Command.java?p2=geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/annotation/Command.java&p1=geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Command.java&r1=572601&r2=573330&rev=573330&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/Command.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/annotation/Command.java Thu Sep 6 11:20:42 2007
@@ -17,24 +17,29 @@
* under the License.
*/
-package org.apache.geronimo.gshell.command;
+package org.apache.geronimo.gshell.command.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+//
+// FIXME: Rename to CommandComponent... so this doesn't class with the Command interface
+//
/**
- * ???
+ * Annotation to mark classes as GShell commands implementations.
*
* @version $Rev$ $Date$
*/
-public interface Command
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface Command
{
- /** Standard command success status code. */
- int SUCCESS = 0;
-
- /** Standard command failure status code. */
- int FAILURE = -1;
+ String name();
- void init(CommandContext context); // throws Exception ?
+ String description() default "";
- Object execute(Object... args) throws Exception;
-
- void destroy(); // throws Exception ?
-}
+ String comment() default "";
+}
\ No newline at end of file
Added: geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/annotation/package-info.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/annotation/package-info.java?rev=573330&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/annotation/package-info.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/annotation/package-info.java Thu Sep 6 11:20:42 2007
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+/**
+ * Provides annotations for GShell.
+ *
+ * @version $Rev$ $Date$
+ */
+package org.apache.geronimo.gshell.command.annotation;
Propchange: geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/annotation/package-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/annotation/package-info.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-api/src/main/java/org/apache/geronimo/gshell/command/annotation/package-info.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/sandbox/gshell/trunk/gshell-assembly/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-assembly/pom.xml?rev=573330&r1=573329&r2=573330&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-assembly/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-assembly/pom.xml Thu Sep 6 11:20:42 2007
@@ -53,6 +53,12 @@
<dependency>
<groupId>org.apache.geronimo.gshell</groupId>
+ <artifactId>gshell-plugin</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.gshell</groupId>
<artifactId>gshell-cli</artifactId>
<version>${pom.version}</version>
</dependency>
Modified: geronimo/sandbox/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Launcher.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Launcher.java?rev=573330&r1=573329&r2=573330&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Launcher.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-bootstrap/src/main/java/org/apache/geronimo/gshell/bootstrap/Launcher.java Thu Sep 6 11:20:42 2007
@@ -39,8 +39,7 @@
assert args != null;
//
- // FIXME: Maybe want to add some kinda of support to allow these "gshell.*" bits to be named
- // for custom branding?
+ // FIXME: Maybe want to add some kinda of support to allow these "gshell.*" bits to be named for custom branding?
//
programName = getProgramName();
Modified: geronimo/sandbox/gshell/trunk/gshell-cli/src/main/resources/META-INF/plexus/plexus.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-cli/src/main/resources/META-INF/plexus/plexus.xml?rev=573330&r1=573329&r2=573330&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-cli/src/main/resources/META-INF/plexus/plexus.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-cli/src/main/resources/META-INF/plexus/plexus.xml Thu Sep 6 11:20:42 2007
@@ -24,12 +24,12 @@
<component-discoverer-manager implementation="org.codehaus.plexus.component.discovery.DefaultComponentDiscovererManager">
<listeners>
<listener implementation="org.codehaus.plexus.component.discovery.DiscoveryListenerDescriptor">
- <role>org.apache.geronimo.gshell.GShellPluginCollector</role>
+ <role>org.apache.geronimo.gshell.plugin.PluginCollector</role>
</listener>
</listeners>
<component-discoverers>
- <component-discoverer implementation="org.apache.geronimo.gshell.GShellPluginDiscoverer"/>
+ <component-discoverer implementation="org.apache.geronimo.gshell.plugin.PluginDiscoverer"/>
</component-discoverers>
</component-discoverer-manager>
@@ -40,13 +40,8 @@
</component>
<component>
- <role>org.apache.geronimo.gshell.GShellPluginCollector</role>
- <implementation>org.apache.geronimo.gshell.GShellPluginCollector</implementation>
- </component>
-
- <component>
- <role>org.apache.geronimo.gshell.GShellPluginCollector</role>
- <implementation>org.apache.geronimo.gshell.GShellPluginCollector</implementation>
+ <role>org.apache.geronimo.gshell.plugin.PluginCollector</role>
+ <implementation>org.apache.geronimo.gshell.plugin.PluginCollector</implementation>
</component>
<component>
Modified: geronimo/sandbox/gshell/trunk/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/ArgumentDescriptor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/ArgumentDescriptor.java?rev=573330&r1=573329&r2=573330&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/ArgumentDescriptor.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/ArgumentDescriptor.java Thu Sep 6 11:20:42 2007
@@ -33,6 +33,11 @@
@Override
public String toString() {
- return metaVar() != null ? metaVar() : "ARG";
+ String tmp = metaVar();
+ if (tmp != null && tmp.length() != 0) {
+ return tmp;
+ }
+
+ return "ARG";
}
}
Modified: geronimo/sandbox/gshell/trunk/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/OptionDescriptor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/OptionDescriptor.java?rev=573330&r1=573329&r2=573330&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/OptionDescriptor.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-clp/src/main/java/org/apache/geronimo/gshell/clp/OptionDescriptor.java Thu Sep 6 11:20:42 2007
@@ -55,7 +55,7 @@
@Override
public String toString() {
- if (aliases.length > 0) {
+ if (aliases != null && aliases.length > 0) {
String str = "";
for (String alias : aliases) {
Modified: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-bsf/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/gshell-bsf/pom.xml?rev=573330&r1=573329&r2=573330&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-bsf/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-bsf/pom.xml Thu Sep 6 11:20:42 2007
@@ -69,13 +69,13 @@
<build>
<plugins>
<plugin>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-java5-maven-plugin</artifactId>
+ <groupId>org.apache.geronimo.gshell</groupId>
+ <artifactId>gshell-maven-plugin</artifactId>
+ <version>${pom.version}</version>
<executions>
<execution>
- <phase>process-classes</phase>
<goals>
- <goal>descriptor</goal>
+ <goal>plugin-descriptor</goal>
</goals>
</execution>
</executions>
Modified: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-bsf/src/main/java/org/apache/geronimo/gshell/commands/bsf/ScriptCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/gshell-bsf/src/main/java/org/apache/geronimo/gshell/commands/bsf/ScriptCommand.java?rev=573330&r1=573329&r2=573330&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-bsf/src/main/java/org/apache/geronimo/gshell/commands/bsf/ScriptCommand.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-bsf/src/main/java/org/apache/geronimo/gshell/commands/bsf/ScriptCommand.java Thu Sep 6 11:20:42 2007
@@ -23,18 +23,17 @@
import org.apache.bsf.BSFManager;
import org.apache.geronimo.gshell.JLineConsole;
import org.apache.geronimo.gshell.clp.Option;
-import org.apache.geronimo.gshell.command.Command;
import org.apache.geronimo.gshell.command.CommandSupport;
import org.apache.geronimo.gshell.command.IO;
+import org.apache.geronimo.gshell.command.annotation.Command;
import org.apache.geronimo.gshell.console.Console;
-import org.codehaus.plexus.component.annotations.Component;
/**
* Provides generic scripting language integration via <a href="http://http://jakarta.apache.org/bsf">BSF</a>.
*
* @version $Rev$ $Date$
*/
-@Component(role= Command.class, hint="script")
+@Command(name="script")
public class ScriptCommand
extends CommandSupport
{
@@ -83,8 +82,6 @@
if (this.interactive) {
log.debug("Starting interactive console...");
-
- IO io = getIO();
Console.Executor executor = new Console.Executor() {
public Result execute(final String line) throws Exception {
Modified: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/pom.xml?rev=573330&r1=573329&r2=573330&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/pom.xml Thu Sep 6 11:20:42 2007
@@ -44,17 +44,17 @@
<version>${pom.version}</version>
</dependency>
</dependencies>
-
+
<build>
<plugins>
<plugin>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-java5-maven-plugin</artifactId>
+ <groupId>org.apache.geronimo.gshell</groupId>
+ <artifactId>gshell-maven-plugin</artifactId>
+ <version>${pom.version}</version>
<executions>
<execution>
- <phase>process-classes</phase>
<goals>
- <goal>descriptor</goal>
+ <goal>plugin-descriptor</goal>
</goals>
</execution>
</executions>
Modified: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/ExitCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/ExitCommand.java?rev=573330&r1=573329&r2=573330&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/ExitCommand.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/ExitCommand.java Thu Sep 6 11:20:42 2007
@@ -21,29 +21,24 @@
import org.apache.geronimo.gshell.ExitNotification;
import org.apache.geronimo.gshell.clp.Argument;
-import org.apache.geronimo.gshell.command.Command;
import org.apache.geronimo.gshell.command.CommandSupport;
-import org.codehaus.plexus.component.annotations.Component;
+import org.apache.geronimo.gshell.command.annotation.Command;
/**
* Exit the current shell.
*
* @version $Rev$ $Date$
*/
-@Component(role=Command.class, hint="exit")
+@Command(name="exit")
public class ExitCommand
extends CommandSupport
{
@Argument(description="System exit code")
private int exitCode = 0;
- protected String getUsage() {
- return super.getUsage() + " [code]";
- }
-
protected Object doExecute() throws Exception {
- log.info("Exiting w/code: " + exitCode);
-
+ log.info("Exiting w/code: {}", exitCode);
+
//
// DO NOT Call System.exit() !!!
//
Modified: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpCommand.java?rev=573330&r1=573329&r2=573330&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpCommand.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpCommand.java Thu Sep 6 11:20:42 2007
@@ -21,11 +21,10 @@
import java.util.List;
-import org.apache.geronimo.gshell.command.Command;
import org.apache.geronimo.gshell.command.CommandSupport;
import org.apache.geronimo.gshell.command.IO;
+import org.apache.geronimo.gshell.command.annotation.Command;
import org.codehaus.plexus.PlexusContainer;
-import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.component.repository.ComponentDescriptor;
@@ -34,7 +33,7 @@
*
* @version $Rev$ $Date$
*/
-@Component(role= Command.class, hint="help")
+@Command(name="help")
public class HelpCommand
extends CommandSupport
{
@@ -44,18 +43,16 @@
protected Object doExecute() throws Exception {
assert container != null;
- IO io = getIO();
-
io.out.println("Available commands:");
- List<ComponentDescriptor> list = container.getComponentDescriptorList(Command.class.getName());
+ List<ComponentDescriptor> list = container.getComponentDescriptorList(org.apache.geronimo.gshell.command.Command.class.getName());
for (ComponentDescriptor desc : list) {
io.out.print(" ");
io.out.print(desc.getRoleHint());
io.out.println();
}
-
+
io.out.println();
return SUCCESS;
Modified: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/SetCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/SetCommand.java?rev=573330&r1=573329&r2=573330&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/SetCommand.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/SetCommand.java Thu Sep 6 11:20:42 2007
@@ -26,18 +26,17 @@
import org.apache.geronimo.gshell.VariablesImpl;
import org.apache.geronimo.gshell.clp.Argument;
import org.apache.geronimo.gshell.clp.Option;
-import org.apache.geronimo.gshell.command.Command;
import org.apache.geronimo.gshell.command.CommandSupport;
import org.apache.geronimo.gshell.command.IO;
import org.apache.geronimo.gshell.command.Variables;
-import org.codehaus.plexus.component.annotations.Component;
+import org.apache.geronimo.gshell.command.annotation.Command;
/**
* Set a variable or property.
*
* @version $Rev$ $Date$
*/
-@Component(role= Command.class, hint="set")
+@Command(name="set")
public class SetCommand
extends CommandSupport
{
@@ -53,22 +52,15 @@
@Argument(description="Variable definition")
private List<String> args;
- protected String getUsage() {
- return super.getUsage() + " (<name[=value>])*";
- }
-
protected Object doExecute() throws Exception {
- IO io = getIO();
-
// No args... list all properties or variables
if (args == null || args.size() == 0) {
switch (mode) {
case PROPERTY: {
Properties props = System.getProperties();
- Iterator iter = props.keySet().iterator();
- while (iter.hasNext()) {
- String name = (String)iter.next();
+ for (Object o : props.keySet()) {
+ String name = (String) o;
String value = props.getProperty(name);
io.out.print(name);
@@ -80,12 +72,11 @@
}
case VARIABLE: {
- Variables vars = getVariables();
- Iterator<String> iter = vars.names();
+ Iterator<String> iter = variables.names();
while (iter.hasNext()) {
String name = iter.next();
- Object value = vars.get(name);
+ Object value = variables.get(name);
io.out.print(name);
io.out.print("=");
@@ -173,7 +164,7 @@
ensureIsIdentifier(nv.name);
// Command vars always has a parent, set only makes sence when setting in parent's scope
- Variables vars = this.getVariables().parent();
+ Variables vars = variables.parent();
vars.set(nv.name, nv.value);
}
Modified: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/SourceCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/SourceCommand.java?rev=573330&r1=573329&r2=573330&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/SourceCommand.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/SourceCommand.java Thu Sep 6 11:20:42 2007
@@ -29,9 +29,8 @@
import org.apache.geronimo.gshell.Shell;
import org.apache.geronimo.gshell.clp.Argument;
-import org.apache.geronimo.gshell.command.Command;
import org.apache.geronimo.gshell.command.CommandSupport;
-import org.codehaus.plexus.component.annotations.Component;
+import org.apache.geronimo.gshell.command.annotation.Command;
import org.codehaus.plexus.component.annotations.Requirement;
/**
@@ -39,7 +38,7 @@
*
* @version $Rev$ $Date$
*/
-@Component(role= Command.class, hint="source")
+@Command(name="source")
public class SourceCommand
extends CommandSupport
{
@@ -48,10 +47,6 @@
@Argument(required=true, description="Source file")
private File file;
-
- protected String getUsage() {
- return super.getUsage() + " <file|url>";
- }
protected Object doExecute() throws Exception {
BufferedReader reader = openReader(file);
Modified: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/UnsetCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/UnsetCommand.java?rev=573330&r1=573329&r2=573330&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/UnsetCommand.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/UnsetCommand.java Thu Sep 6 11:20:42 2007
@@ -24,17 +24,16 @@
import org.apache.geronimo.gshell.VariablesImpl;
import org.apache.geronimo.gshell.clp.Argument;
import org.apache.geronimo.gshell.clp.Option;
-import org.apache.geronimo.gshell.command.Command;
import org.apache.geronimo.gshell.command.CommandSupport;
import org.apache.geronimo.gshell.command.Variables;
-import org.codehaus.plexus.component.annotations.Component;
+import org.apache.geronimo.gshell.command.annotation.Command;
/**
* Unset a variable or property.
*
* @version $Rev$ $Date$
*/
-@Component(role= Command.class, hint="exit")
+@Command(name="unset")
public class UnsetCommand
extends CommandSupport
{
@@ -88,7 +87,7 @@
ensureIsIdentifier(name);
// Command vars always has a parent, set only makes sence when setting in parent's scope
- Variables vars = this.getVariables().parent();
+ Variables vars = variables.parent();
vars.unset(name);
}
Modified: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/pom.xml?rev=573330&r1=573329&r2=573330&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/pom.xml Thu Sep 6 11:20:42 2007
@@ -40,13 +40,13 @@
<build>
<plugins>
<plugin>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-java5-maven-plugin</artifactId>
+ <groupId>org.apache.geronimo.gshell</groupId>
+ <artifactId>gshell-maven-plugin</artifactId>
+ <version>${pom.version}</version>
<executions>
<execution>
- <phase>process-classes</phase>
<goals>
- <goal>descriptor</goal>
+ <goal>plugin-descriptor</goal>
</goals>
</execution>
</executions>
Modified: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/CatCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/CatCommand.java?rev=573330&r1=573329&r2=573330&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/CatCommand.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/CatCommand.java Thu Sep 6 11:20:42 2007
@@ -30,10 +30,9 @@
import org.apache.geronimo.gshell.clp.Argument;
import org.apache.geronimo.gshell.clp.Option;
-import org.apache.geronimo.gshell.command.Command;
import org.apache.geronimo.gshell.command.CommandSupport;
import org.apache.geronimo.gshell.command.IO;
-import org.codehaus.plexus.component.annotations.Component;
+import org.apache.geronimo.gshell.command.annotation.Command;
import org.codehaus.plexus.util.StringUtils;
/**
@@ -41,7 +40,7 @@
*
* @version $Rev$ $Date$
*/
-@Component(role= Command.class, hint="cat")
+@Command(name="cat")
public class CatCommand
extends CommandSupport
{
@@ -51,13 +50,7 @@
@Argument(description="File or URL", required=true)
private List<String> args;
- protected String getUsage() {
- return super.getUsage() + " [<file|url> ...]";
- }
-
protected Object doExecute() throws Exception {
- IO io = getIO();
-
//
// Support "-" if length is one, and read from io.in
// This will help test command pipelines.
Modified: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/EchoCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/EchoCommand.java?rev=573330&r1=573329&r2=573330&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/EchoCommand.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/EchoCommand.java Thu Sep 6 11:20:42 2007
@@ -23,17 +23,16 @@
import org.apache.geronimo.gshell.clp.Argument;
import org.apache.geronimo.gshell.clp.Option;
-import org.apache.geronimo.gshell.command.Command;
import org.apache.geronimo.gshell.command.CommandSupport;
import org.apache.geronimo.gshell.command.IO;
-import org.codehaus.plexus.component.annotations.Component;
+import org.apache.geronimo.gshell.command.annotation.Command;
/**
* A simple command to <em>echo</em> all given arguments to the commands standard output.
*
* @version $Rev$ $Date$
*/
-@Component(role= Command.class, hint="echo")
+@Command(name="echo")
public class EchoCommand
extends CommandSupport
{
@@ -44,8 +43,6 @@
private List<String> args;
protected Object doExecute() throws Exception {
- IO io = getIO();
-
if (args != null) {
int c=0;
Modified: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/ExecuteCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/ExecuteCommand.java?rev=573330&r1=573329&r2=573330&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/ExecuteCommand.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/ExecuteCommand.java Thu Sep 6 11:20:42 2007
@@ -22,19 +22,17 @@
import java.util.List;
import org.apache.geronimo.gshell.clp.Argument;
-import org.apache.geronimo.gshell.command.Command;
import org.apache.geronimo.gshell.command.CommandSupport;
import org.apache.geronimo.gshell.command.IO;
+import org.apache.geronimo.gshell.command.annotation.Command;
import org.apache.geronimo.gshell.common.io.PumpStreamHandler;
-import org.codehaus.plexus.component.annotations.Component;
/**
* Execute system processes.
*
* @version $Rev$ $Date$
*/
-@Component(role= Command.class, hint="exec")
-public class ExecuteCommand
+@Command(name="exec")public class ExecuteCommand
extends CommandSupport
{
private ProcessBuilder builder;
@@ -42,20 +40,10 @@
@Argument(description="Argument", required=true)
private List<String> args;
- protected String getUsage() {
- return super.getUsage() + " <command> (<arg>)*";
- }
-
protected Object doExecute() throws Exception {
assert builder != null;
- boolean info = log.isInfoEnabled();
-
- if (info) {
- log.info("Executing: " + builder.command());
- }
-
- IO io = getIO();
+ log.info("Executing: {}", builder.command());
//
// TODO: May need to expose the Process's destroy() if Command abort() is issued?
@@ -71,9 +59,8 @@
int status = p.waitFor();
- if (info) {
- log.info("Process exited w/status: " + status);
- }
+
+ log.info("Process exited w/status: {}", status);
handler.stop();
Modified: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/JavaCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/JavaCommand.java?rev=573330&r1=573329&r2=573330&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/JavaCommand.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/JavaCommand.java Thu Sep 6 11:20:42 2007
@@ -24,10 +24,9 @@
import org.apache.geronimo.gshell.clp.Argument;
import org.apache.geronimo.gshell.clp.Option;
-import org.apache.geronimo.gshell.command.Command;
import org.apache.geronimo.gshell.command.CommandSupport;
+import org.apache.geronimo.gshell.command.annotation.Command;
import org.apache.geronimo.gshell.common.Arguments;
-import org.codehaus.plexus.component.annotations.Component;
/**
* Execute a Java standard application.
@@ -38,22 +37,18 @@
*
* @version $Rev$ $Date$
*/
-@Component(role= Command.class, hint="java")
+@Command(name="java")
public class JavaCommand
extends CommandSupport
{
- @Option(name="-m", aliases={"--method"}, description="Invoke a named method")
+ @Option(name="-m", aliases={"--method"}, metaVar="METHOD", description="Invoke a named method")
private String methodName = "main";
- @Argument(index=0, description="Class name", required=true)
+ @Argument(index=0, metaVar="CLASSNAME", description="The name of the class to invoke", required=true)
private String className;
- @Argument(index=1, description="Arguments")
+ @Argument(index=1, metaVar="ARG", description="Arguments to pass to the METHOD of CLASSNAME")
private List<String> args;
-
- protected String getUsage() {
- return super.getUsage() + " <classname> [arguments]";
- }
protected Object doExecute() throws Exception {
boolean info = log.isInfoEnabled();
Modified: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/SleepCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/SleepCommand.java?rev=573330&r1=573329&r2=573330&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/SleepCommand.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/SleepCommand.java Thu Sep 6 11:20:42 2007
@@ -20,26 +20,21 @@
package org.apache.geronimo.gshell.commands.optional;
import org.apache.geronimo.gshell.clp.Argument;
-import org.apache.geronimo.gshell.command.Command;
import org.apache.geronimo.gshell.command.CommandSupport;
-import org.codehaus.plexus.component.annotations.Component;
+import org.apache.geronimo.gshell.command.annotation.Command;
/**
* Sleep... zzzZ
*
* @version $Rev$ $Date$
*/
-@Component(role= Command.class, hint="sleep")
+@Command(name="sleep")
public class SleepCommand
extends CommandSupport
{
@Argument(description="Time in milliseconds", required=true)
private int time = -1;
-
- protected String getUsage() {
- return super.getUsage() + " <milliseconds>";
- }
-
+
protected Object doExecute() throws Exception {
log.info("Sleeping for " + time);
Modified: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/WaitCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/WaitCommand.java?rev=573330&r1=573329&r2=573330&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/WaitCommand.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/WaitCommand.java Thu Sep 6 11:20:42 2007
@@ -19,9 +19,8 @@
package org.apache.geronimo.gshell.commands.optional;
-import org.apache.geronimo.gshell.command.Command;
import org.apache.geronimo.gshell.command.CommandSupport;
-import org.codehaus.plexus.component.annotations.Component;
+import org.apache.geronimo.gshell.command.annotation.Command;
//
// HACK: This is a temporary to handle shells which need to keep around after running
@@ -33,7 +32,7 @@
*
* @version $Rev$ $Date$
*/
-@Component(role= Command.class, hint="wait")
+@Command(name="wait")
public class WaitCommand
extends CommandSupport
{
Modified: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs/pom.xml?rev=573330&r1=573329&r2=573330&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs/pom.xml Thu Sep 6 11:20:42 2007
@@ -48,18 +48,18 @@
<build>
<plugins>
<plugin>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-java5-maven-plugin</artifactId>
+ <groupId>org.apache.geronimo.gshell</groupId>
+ <artifactId>gshell-maven-plugin</artifactId>
+ <version>${pom.version}</version>
<executions>
<execution>
- <phase>process-classes</phase>
<goals>
- <goal>descriptor</goal>
+ <goal>plugin-descriptor</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
-
+
</project>
Modified: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyCommand.java?rev=573330&r1=573329&r2=573330&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyCommand.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyCommand.java Thu Sep 6 11:20:42 2007
@@ -23,15 +23,14 @@
import org.apache.commons.vfs.FileSystemManager;
import org.apache.commons.vfs.FileUtil;
import org.apache.geronimo.gshell.clp.Argument;
-import org.apache.geronimo.gshell.command.Command;
-import org.codehaus.plexus.component.annotations.Component;
+import org.apache.geronimo.gshell.command.annotation.Command;
/**
* Copy files.
*
* @version $Rev$ $Date$
*/
-@Component(role= Command.class, hint="copy")
+@Command(name="copy")
public class CopyCommand
extends VFSCommandSupport
{
@@ -41,17 +40,13 @@
@Argument(index=1, required=true, description="Target")
private String targetName;
- protected String getUsage() {
- return super.getUsage() + " <source> <target>";
- }
-
protected Object doExecute() throws Exception {
FileSystemManager fsm = getFileSystemManager();
FileObject source = fsm.resolveFile(sourceName);
FileObject target = fsm.resolveFile(targetName);
- log.info("Copying " + source + " -> " + target);
-
+ log.info("Copying {} -> {}", source, target);
+
FileUtil.copyContent(source, target);
return SUCCESS;
Modified: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/VFSCommandSupport.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/VFSCommandSupport.java?rev=573330&r1=573329&r2=573330&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/VFSCommandSupport.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/VFSCommandSupport.java Thu Sep 6 11:20:42 2007
@@ -21,6 +21,7 @@
import org.apache.commons.vfs.FileSystemManager;
import org.apache.commons.vfs.VFS;
+import org.apache.commons.vfs.FileSystemException;
import org.apache.geronimo.gshell.command.CommandSupport;
/**
@@ -33,19 +34,14 @@
{
private FileSystemManager fsManager;
- protected void doInit() throws Exception {
- //
- // TODO: Should probably bind this pupping into the container and let plexus handle it for us... though
- // the components.xml generation will clobber anything which we add, it won't merge like a good like
- // plugin should... :-(
- //
-
- fsManager = VFS.getManager();
- }
-
protected FileSystemManager getFileSystemManager() {
if (fsManager == null) {
- throw new IllegalStateException("Not initialized; Missing FileSystemManager");
+ try {
+ fsManager = VFS.getManager();
+ }
+ catch (FileSystemException e) {
+ throw new RuntimeException(e);
+ }
}
return fsManager;
Modified: geronimo/sandbox/gshell/trunk/gshell-common/src/main/java/org/apache/geronimo/gshell/common/StopWatch.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-common/src/main/java/org/apache/geronimo/gshell/common/StopWatch.java?rev=573330&r1=573329&r2=573330&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-common/src/main/java/org/apache/geronimo/gshell/common/StopWatch.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-common/src/main/java/org/apache/geronimo/gshell/common/StopWatch.java Thu Sep 6 11:20:42 2007
@@ -92,6 +92,12 @@
super();
}
+ public StopWatch(final boolean start) {
+ if (start) {
+ start();
+ }
+ }
+
/**
* <p>Start the stopwatch.</p>
*
Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/Shell.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/Shell.java?rev=573330&r1=573329&r2=573330&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/Shell.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/Shell.java Thu Sep 6 11:20:42 2007
@@ -19,173 +19,31 @@
package org.apache.geronimo.gshell;
-import java.util.Iterator;
-
-import org.apache.geronimo.gshell.command.Command;
-import org.apache.geronimo.gshell.command.CommandContext;
import org.apache.geronimo.gshell.command.IO;
import org.apache.geronimo.gshell.command.Variables;
-import org.apache.geronimo.gshell.common.Arguments;
-import org.apache.geronimo.gshell.common.StopWatch;
-import org.apache.geronimo.gshell.layout.LayoutManager;
-import org.codehaus.plexus.PlexusContainer;
-import org.codehaus.plexus.component.annotations.Component;
-import org.codehaus.plexus.component.annotations.Requirement;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* This is the primary interface to executing named commands.
*
* @version $Rev$ $Date$
*/
-@Component(role = Shell.class)
-public class Shell
- implements Initializable
+public interface Shell
{
- private Logger log = LoggerFactory.getLogger(getClass());
-
- @Requirement
- private IO io;
-
- @Requirement
- private PlexusContainer container;
-
- @Requirement
- private LayoutManager layoutManager;
-
- @Requirement
- private CommandLineBuilder commandLineBuilder;
-
- private Variables variables = new VariablesImpl();
-
- public Shell() {
- //
- // HACK: Set some default variables
- //
-
- variables.set("gshell.prompt", "> ");
- }
-
//
- // HACK: This is for testing, need to weed out and refactor all this shiz
+ // FIXME: Move to gshell-api
//
-
- public Shell(final IO io) {
- this.io = io;
- }
-
- public Variables getVariables() {
- return variables;
- }
-
- public IO getIO() {
- return io;
- }
-
- public void initialize() throws InitializationException {
- // Dump some debug to crapski
- if (log.isDebugEnabled()) {
- log.debug("Container: {}", container);
- log.debug("Layout manager: {}", layoutManager);
- log.debug("Builder: {}", commandLineBuilder);
- }
- }
-
- public Object execute(final String commandLine) throws Exception {
- assert commandLine != null;
-
- if (log.isInfoEnabled()) {
- log.info("Executing (String): " + commandLine);
- }
-
- CommandLine cl = commandLineBuilder.create(commandLine);
- return cl.execute();
- }
//
- // CommandExecutor
+ // TODO: Just expose the Enviroment
//
- private void dump(final Variables vars) {
- Iterator<String> iter = vars.names();
-
- if (iter.hasNext()) {
- log.debug("Variables:");
- }
+ IO getIO();
- while (iter.hasNext()) {
- String name = iter.next();
- log.debug(" {}={}", name, vars.get(name));
- }
- }
-
- public Object execute(final String commandName, final Object[] args) throws Exception {
- assert commandName != null;
- assert args != null;
-
- boolean debug = log.isDebugEnabled();
-
- if (log.isInfoEnabled()) {
- log.info("Executing (" + commandName + "): " + Arguments.asString(args));
- }
-
- //
- // HACK: Probably need to pick a better way to name the command invocation container, or do we even really need this?
- //
-
- final PlexusContainer childContainer = container.createChildContainer("command-invocation", container.getContainerRealm());
- final Command command = (Command)childContainer.lookup(Command.class, commandName);
- final Variables vars = new VariablesImpl(getVariables());
-
- command.init(new CommandContext() {
- public IO getIO() {
- return io;
- }
-
- public Variables getVariables() {
- return vars;
- }
- });
-
- // Setup command timings
- StopWatch watch = null;
- if (debug) {
- watch = new StopWatch();
- watch.start();
- }
-
- Object result;
- try {
- result = command.execute(args);
-
- if (debug) {
- log.debug("Command completed in " + watch);
- }
- }
- finally {
- command.destroy();
-
- //
- // HACK: Nuke the child container now
- //
-
- container.removeChildContainer("command-invocation");
- }
-
- return result;
- }
-
- public Object execute(final Object... args) throws Exception {
- assert args != null;
- assert args.length > 1;
-
- if (log.isInfoEnabled()) {
- log.info("Executing (Object...): " + Arguments.asString(args));
- }
+ Variables getVariables();
+
+ Object execute(String line) throws Exception;
+
+ Object execute(String command, final Object[] args) throws Exception;
- return execute(String.valueOf(args[0]), Arguments.shift(args));
- }
+ Object execute(Object... args) throws Exception;
}
Copied: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ShellImpl.java (from r572601, geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/Shell.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ShellImpl.java?p2=geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ShellImpl.java&p1=geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/Shell.java&r1=572601&r2=573330&rev=573330&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/Shell.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ShellImpl.java Thu Sep 6 11:20:42 2007
@@ -19,8 +19,6 @@
package org.apache.geronimo.gshell;
-import java.util.Iterator;
-
import org.apache.geronimo.gshell.command.Command;
import org.apache.geronimo.gshell.command.CommandContext;
import org.apache.geronimo.gshell.command.IO;
@@ -37,13 +35,13 @@
import org.slf4j.LoggerFactory;
/**
- * This is the primary interface to executing named commands.
+ * This is the primary implementation of {@link Shell}.
*
* @version $Rev$ $Date$
*/
-@Component(role = Shell.class)
-public class Shell
- implements Initializable
+@Component(role=Shell.class)
+public class ShellImpl
+ implements Shell, Initializable
{
private Logger log = LoggerFactory.getLogger(getClass());
@@ -59,24 +57,20 @@
@Requirement
private CommandLineBuilder commandLineBuilder;
- private Variables variables = new VariablesImpl();
+ private final Variables variables = new VariablesImpl();
- public Shell() {
- //
- // HACK: Set some default variables
- //
-
- variables.set("gshell.prompt", "> ");
+ public ShellImpl() {
+ // empty
}
//
// HACK: This is for testing, need to weed out and refactor all this shiz
//
-
- public Shell(final IO io) {
+
+ public ShellImpl(final IO io) {
this.io = io;
}
-
+
public Variables getVariables() {
return variables;
}
@@ -96,7 +90,7 @@
public Object execute(final String commandLine) throws Exception {
assert commandLine != null;
-
+
if (log.isInfoEnabled()) {
log.info("Executing (String): " + commandLine);
}
@@ -105,42 +99,30 @@
return cl.execute();
}
- //
- // CommandExecutor
- //
-
- private void dump(final Variables vars) {
- Iterator<String> iter = vars.names();
-
- if (iter.hasNext()) {
- log.debug("Variables:");
- }
-
- while (iter.hasNext()) {
- String name = iter.next();
- log.debug(" {}={}", name, vars.get(name));
- }
- }
-
public Object execute(final String commandName, final Object[] args) throws Exception {
assert commandName != null;
assert args != null;
- boolean debug = log.isDebugEnabled();
-
- if (log.isInfoEnabled()) {
- log.info("Executing (" + commandName + "): " + Arguments.asString(args));
- }
+ log.info("Executing ({}): {}", commandName, Arguments.asString(args));
//
// HACK: Probably need to pick a better way to name the command invocation container, or do we even really need this?
//
- final PlexusContainer childContainer = container.createChildContainer("command-invocation", container.getContainerRealm());
+ String realmId = "command-invocation";
+
+ final PlexusContainer childContainer = container.createChildContainer(realmId, container.getContainerRealm());
final Command command = (Command)childContainer.lookup(Command.class, commandName);
- final Variables vars = new VariablesImpl(getVariables());
- command.init(new CommandContext() {
+
+ //
+ // NOTE: For now, until we can figure out a better way to have the container deal with this stuff, pass in
+ // the execution context manually
+ //
+
+ CommandContext context = new CommandContext() {
+ final Variables vars = new VariablesImpl(ShellImpl.this.getVariables());
+
public IO getIO() {
return io;
}
@@ -148,31 +130,31 @@
public Variables getVariables() {
return vars;
}
- });
+ };
+
+ command.init(context);
// Setup command timings
- StopWatch watch = null;
- if (debug) {
- watch = new StopWatch();
- watch.start();
- }
+ StopWatch watch = new StopWatch(true);
Object result;
try {
result = command.execute(args);
- if (debug) {
- log.debug("Command completed in " + watch);
- }
+ log.debug("Command completed in: {}", watch);
}
finally {
- command.destroy();
+ // Make sure that the commands output has been flushed
+ try {
+ io.flush();
+ }
+ catch (Exception ignore) {}
//
// HACK: Nuke the child container now
//
-
- container.removeChildContainer("command-invocation");
+
+ container.removeChildContainer(realmId);
}
return result;
@@ -182,10 +164,8 @@
assert args != null;
assert args.length > 1;
- if (log.isInfoEnabled()) {
- log.info("Executing (Object...): " + Arguments.asString(args));
- }
+ log.info("Executing (Object...): {}", Arguments.asString(args));
return execute(String.valueOf(args[0]), Arguments.shift(args));
}
-}
+}
\ No newline at end of file
Copied: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ShellInfoImpl.java (from r572601, geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/EnvironmentImpl.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ShellInfoImpl.java?p2=geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ShellInfoImpl.java&p1=geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/EnvironmentImpl.java&r1=572601&r2=573330&rev=573330&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/EnvironmentImpl.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ShellInfoImpl.java Thu Sep 6 11:20:42 2007
@@ -22,7 +22,7 @@
import java.io.File;
import java.io.IOException;
-import org.apache.geronimo.gshell.command.Environment;
+import org.apache.geronimo.gshell.command.ShellInfo;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
@@ -30,13 +30,13 @@
import org.slf4j.LoggerFactory;
/**
- * The default/standard/whatever implementation of {@link Environment}.
+ * Provides some runtime information about the shell.
*
* @version $Rev$ $Date$
*/
-@Component(role=Environment.class)
-public class EnvironmentImpl
- implements Environment, Initializable
+@Component(role=ShellInfo.class)
+public class ShellInfoImpl
+ implements ShellInfo, Initializable
{
private final Logger log = LoggerFactory.getLogger(getClass());
@@ -62,7 +62,7 @@
String homePath = System.getProperty("gshell.home");
if (homePath == null) {
- throw new InitializationException("The 'gsell.home' property must be set for the shell to function correctly");
+ throw new InitializationException("The 'gshell.home' property must be set for the shell to function correctly");
}
// And now lets resolve this sucker
@@ -81,15 +81,4 @@
return dir;
}
-
- //
- // TODO: Merge in the other command-context and variable access muck here. The Environment for the shell should be the one place
- // were all state is stored, so we can use this to multiplex shells and provide commands with a simple/single interface
- // for interacting with the user.
- //
- // IO
- // Variables
- // Shell information
- // Current command descriptor
- //
}
Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ShellInfoImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ShellInfoImpl.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ShellInfoImpl.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/gshell/trunk/gshell-core/src/main/resources/META-INF/plexus/plexus.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/resources/META-INF/plexus/plexus.xml?rev=573330&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/resources/META-INF/plexus/plexus.xml (added)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/resources/META-INF/plexus/plexus.xml Thu Sep 6 11:20:42 2007
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<plexus>
+
+ <!--
+ <component-factory-manager implementation="org.codehaus.plexus.component.factory.DefaultComponentFactoryManager">
+ <component-factories>
+ <component-factory implementation="org.apache.geronimo.gshell.EnvironmentManagerImpl">
+ <id>environment</id>
+ </component-factory>
+ </component-factories>
+ </component-factory-manager>
+ -->
+
+</plexus>
\ No newline at end of file
Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/resources/META-INF/plexus/plexus.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/resources/META-INF/plexus/plexus.xml
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/resources/META-INF/plexus/plexus.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml