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 2006/05/30 05:00:26 UTC
svn commit: r410176 - in /geronimo/sandbox/gshell/trunk:
gshell-assembly/src/main/config/
gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/
gshell-commands/scripting-commands/src/main/java/org/apache/geronimo/gshell/commands/scripting/
gshell-co...
Author: jdillon
Date: Mon May 29 20:00:25 2006
New Revision: 410176
URL: http://svn.apache.org/viewvc?rev=410176&view=rev
Log:
Removed the remaining spring bits, reduces lib size by ~1mb :-)
Removed:
geronimo/sandbox/gshell/trunk/gshell-assembly/src/main/config/gshell.xml
geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/GShellImpl.java
Modified:
geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
geronimo/sandbox/gshell/trunk/gshell-commands/scripting-commands/src/main/java/org/apache/geronimo/gshell/commands/scripting/ScriptCommand.java
geronimo/sandbox/gshell/trunk/gshell-commands/standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/HelpCommand.java
geronimo/sandbox/gshell/trunk/gshell-core/pom.xml
geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/GShell.java
geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandManager.java
Modified: geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java?rev=410176&r1=410175&r2=410176&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java Mon May 29 20:00:25 2006
@@ -110,15 +110,15 @@
options.addOption(OptionBuilder.withLongOpt("debug")
.withDescription("Enable DEBUG logging output")
- .create());
+ .create("debug"));
options.addOption(OptionBuilder.withLongOpt("verbose")
.withDescription("Enable INFO logging output")
- .create());
+ .create("verbose"));
options.addOption(OptionBuilder.withLongOpt("quiet")
.withDescription("Limit logging output to ERROR")
- .create());
+ .create("quiet"));
CommandLineParser parser = new PosixParser();
CommandLine line = parser.parse(options, args, true);
Modified: geronimo/sandbox/gshell/trunk/gshell-commands/scripting-commands/src/main/java/org/apache/geronimo/gshell/commands/scripting/ScriptCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/scripting-commands/src/main/java/org/apache/geronimo/gshell/commands/scripting/ScriptCommand.java?rev=410176&r1=410175&r2=410176&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/scripting-commands/src/main/java/org/apache/geronimo/gshell/commands/scripting/ScriptCommand.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/scripting-commands/src/main/java/org/apache/geronimo/gshell/commands/scripting/ScriptCommand.java Mon May 29 20:00:25 2006
@@ -16,18 +16,12 @@
package org.apache.geronimo.gshell.commands.scripting;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.PosixParser;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.HelpFormatter;
-import org.apache.commons.lang.StringUtils;
import org.apache.geronimo.gshell.command.Command;
import org.apache.geronimo.gshell.command.CommandSupport;
@@ -48,8 +42,7 @@
private boolean interactive = false;
- private String expression
- ;
+ private String expression;
public ScriptCommand() {
super("script");
Modified: geronimo/sandbox/gshell/trunk/gshell-commands/standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/HelpCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/HelpCommand.java?rev=410176&r1=410175&r2=410176&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/HelpCommand.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/HelpCommand.java Mon May 29 20:00:25 2006
@@ -22,15 +22,10 @@
import org.apache.commons.cli.OptionBuilder;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.PosixParser;
+
import org.apache.geronimo.gshell.command.Command;
import org.apache.geronimo.gshell.command.CommandSupport;
import org.apache.geronimo.gshell.console.IO;
-import org.springframework.beans.BeansException;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.ApplicationContextAware;
-
-import java.util.Iterator;
-import java.util.Map;
/**
* Display command help
@@ -39,7 +34,6 @@
*/
public class HelpCommand
extends CommandSupport
- implements ApplicationContextAware
{
public HelpCommand() {
super("help");
@@ -88,6 +82,9 @@
// HACK: For now just list all know commands
//
+ throw new Exception("Pending re-impl... sorry :-(");
+
+ /*
Map commands = ctx.getBeansOfType(Command.class);
Iterator iter = commands.keySet().iterator();
@@ -99,17 +96,6 @@
}
return Command.SUCCESS;
- }
-
- //
- // ApplicationContextAware
- //
-
- private ApplicationContext ctx;
-
- public void setApplicationContext(final ApplicationContext applicationContext) throws BeansException {
- assert applicationContext != null;
-
- this.ctx = applicationContext;
+ */
}
}
Modified: geronimo/sandbox/gshell/trunk/gshell-core/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/pom.xml?rev=410176&r1=410175&r2=410176&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/pom.xml Mon May 29 20:00:25 2006
@@ -26,30 +26,6 @@
<dependencies>
<dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-core</artifactId>
- <version>${spring.version}</version>
- <type>jar</type>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- <version>${spring.version}</version>
- <type>jar</type>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-beans</artifactId>
- <version>${spring.version}</version>
- <type>jar</type>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
<groupId>jline</groupId>
<artifactId>jline</artifactId>
</dependency>
Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/GShell.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/GShell.java?rev=410176&r1=410175&r2=410176&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/GShell.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/GShell.java Mon May 29 20:00:25 2006
@@ -20,8 +20,14 @@
import org.apache.commons.logging.LogFactory;
import org.apache.geronimo.gshell.console.IO;
import org.apache.geronimo.gshell.command.CommandExecutor;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.apache.geronimo.gshell.command.Command;
+import org.apache.geronimo.gshell.command.CommandManager;
+import org.apache.geronimo.gshell.command.CommandContext;
+import org.apache.geronimo.gshell.command.Variables;
+import org.apache.geronimo.gshell.command.VariablesMap;
+import org.apache.geronimo.gshell.commandline.CommandLineBuilder;
+import org.apache.geronimo.gshell.commandline.CommandLine;
+import org.apache.geronimo.gshell.util.Arguments;
/**
* ???
@@ -32,35 +38,90 @@
implements CommandExecutor
{
private static final Log log = LogFactory.getLog(GShell.class);
-
- private ApplicationContext ctx;
- private GShellImpl impl;
-
+ private final IO io;
+
public GShell(final IO io) {
- assert io != null;
-
- this.ctx = new ClassPathXmlApplicationContext(new String[] {
- "classpath*:/gshell.xml",
- });
-
- this.impl = (GShellImpl)ctx.getBean("gshell");
- this.impl.setIO(io);
+ if (io == null) {
+ throw new IllegalArgumentException("IO is null");
+ }
+
+ this.io = io;
}
public GShell() {
this(new IO());
}
-
- public int execute(final String args) throws Exception {
- return impl.execute(args);
- }
-
- public int execute(final String[] args) throws Exception {
- return impl.execute(args);
+
+ public int execute(final String commandLine) throws Exception {
+ assert commandLine != null;
+
+ log.info("Executing (String): " + commandLine);
+
+ //
+ // HACK: Just to get something to work...
+ //
+
+ CommandLineBuilder builder = new CommandLineBuilder(this);
+ CommandLine cl = builder.create(commandLine);
+ cl.execute();
+
+ //
+ // HACK: Current API needs to be revised to pass data back,
+ // will be fixed latger, ignore for now
+ //
+
+ return 0;
}
-
+
public int execute(final String commandName, String[] args) throws Exception {
- return impl.execute(commandName, args);
+ assert commandName != null;
+ assert args != null;
+
+ log.info("Executing (" + commandName + "): " + java.util.Arrays.asList(args));
+
+ //
+ // HACK: Just get something working right now
+ //
+
+ //
+ // HACK: DI CommandManager...
+ //
+
+ Command cmd = new CommandManager().getCommand(commandName);
+
+ // Command cmd = (Command)ctx.getBean(commandName);
+
+ cmd.init(new CommandContext() {
+ Variables vars = new VariablesMap();
+
+ public IO getIO() {
+ return io;
+ }
+
+ public Variables getVariables() {
+ return vars;
+ }
+ });
+
+ int status;
+
+ try {
+ status = cmd.execute(args);
+ }
+ finally {
+ cmd.destroy();
+ }
+
+ return status;
+ }
+
+ public int execute(final String[] args) throws Exception {
+ assert args != null;
+ assert args.length > 1;
+
+ log.info("Executing (String[]): " + java.util.Arrays.asList(args));
+
+ return execute(args[0], Arguments.shift(args));
}
}
Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandManager.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandManager.java?rev=410176&r1=410175&r2=410176&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandManager.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandManager.java Mon May 29 20:00:25 2006
@@ -60,12 +60,4 @@
return cmd;
}
-
- //
- // HACK: Testing...
- //
-
- public static void main(final String[] args) throws Exception {
- new CommandManager();
- }
}