geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r574416 [1/3] - in /geronimo/sandbox/gshell/trunk: ./ gshell-assembly/ gshell-cli/ gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/ gshell-cli/src/main/resources/META-INF/plexus/ gshell-cli/src/main/resources/org/ gshell-command-api...
Date Tue, 11 Sep 2007 00:49:19 GMT
Author: jdillon
Date: Mon Sep 10 17:49:15 2007
New Revision: 574416

URL: http://svn.apache.org/viewvc?rev=574416&view=rev
Log:
Created facade to simplify container construction and facilitate simple usage
Renamed flavor to branding
Update many places to use the branding to get well... branding details
Moved a bunch of common init to DefaultShell
Added factory lookups for IO, Environment and Terminal
Fixed type problem with Arguments.shift()
Go back to using ${version} for now
Bring back JEXL to handle the ${} expansion.  For a little more weight it adds a lot of use functionality
Bind ${env} to the map of environment variables for easy shell access
Put the shell related interfaces into o.a.g.g.shell
Add the local host to the shell info obj
Split up Shell intf into InteractiveShell and CommandExecutor
Split up adding DefaultCommandExecutor, moved out from DefaultShell to componentize
Adding a nicer prompt
Moved "echo" to builtins
Eh, probably a lot of other stuff too

Added:
    geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/CommandExecutor.java
      - copied, changed from r573981, geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/Shell.java
    geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/
    geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/Environment.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/InteractiveShell.java   (contents, props changed)
      - copied, changed from r573981, geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/Shell.java
    geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/Shell.java   (contents, props changed)
      - copied, changed from r573981, geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/Shell.java
    geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/ShellInfo.java   (contents, props changed)
      - copied, changed from r573981, geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/ShellInfo.java
    geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/package-info.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/EchoCommand.java
      - copied, changed from r573981, geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/EchoCommand.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultCommandExecutor.java
      - copied, changed from r573981, geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShell.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/GShell.java
      - copied, changed from r573981, geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/CommandLine.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/Branding.java   (contents, props changed)
      - copied, changed from r573981, geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/Flavor.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/DefaultBranding.java   (contents, props changed)
      - copied, changed from r573981, geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/VanillaFlavor.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/PropertiesVersionLoader.java   (contents, props changed)
      - copied, changed from r573981, geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/PropertiesVersionLoader.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/VersionLoader.java   (contents, props changed)
      - copied, changed from r573981, geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/VersionLoader.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/package-info.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/TerminalFactory.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/TerminalInfo.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/expression/
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/expression/ExpressionEvaluator.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/expression/JexlExpressionEvaluator.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/expression/package-info.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/lookup/
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/lookup/EnvironmentLookup.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/lookup/IOLookup.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/lookup/LookupFactorySupport.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/lookup/package-info.java   (with props)
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/resources/org/
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/resources/org/apache/
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/resources/org/apache/geronimo/
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/resources/org/apache/geronimo/gshell/
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/resources/org/apache/geronimo/gshell/branding/
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/resources/org/apache/geronimo/gshell/branding/version.properties   (contents, props changed)
      - copied, changed from r573981, geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/resources/org/apache/geronimo/gshell/flavor/version.properties
    geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/expression/
    geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/expression/JexlExpressionEvaluatorTest.java   (with props)
Removed:
    geronimo/sandbox/gshell/trunk/gshell-cli/src/main/resources/org/
    geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/Shell.java
    geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/ShellInfo.java
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/TestCommand.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-core/src/main/resources/META-INF/
    geronimo/sandbox/gshell/trunk/gshell-flavor/
Modified:
    geronimo/sandbox/gshell/trunk/gshell-assembly/pom.xml
    geronimo/sandbox/gshell/trunk/gshell-cli/pom.xml
    geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
    geronimo/sandbox/gshell/trunk/gshell-cli/src/main/resources/META-INF/plexus/plexus.xml
    geronimo/sandbox/gshell/trunk/gshell-command-api/pom.xml
    geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java
    geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/Variables.java
    geronimo/sandbox/gshell/trunk/gshell-commands/gshell-bsf/pom.xml
    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/HelpCommand.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-optional/pom.xml
    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-vfs/pom.xml
    geronimo/sandbox/gshell/trunk/gshell-commands/pom.xml
    geronimo/sandbox/gshell/trunk/gshell-core/pom.xml
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/CommandLineBuilder.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShell.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShellInfo.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ExecutingVisitor.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ShellSecurityManager.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/JLineConsole.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/loader/XMLLayoutLoader.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/mdo/layout.mdo
    geronimo/sandbox/gshell/trunk/gshell-maven-plugin/pom.xml
    geronimo/sandbox/gshell/trunk/gshell-parser/pom.xml
    geronimo/sandbox/gshell/trunk/gshell-support/gshell-ansi/pom.xml
    geronimo/sandbox/gshell/trunk/gshell-support/gshell-clp/pom.xml
    geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/Arguments.java
    geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/test/java/org/apache/geronimo/gshell/common/ArgumentsTest.java
    geronimo/sandbox/gshell/trunk/gshell-support/gshell-i18n/pom.xml
    geronimo/sandbox/gshell/trunk/gshell-support/gshell-prefs/pom.xml
    geronimo/sandbox/gshell/trunk/pom.xml

Modified: geronimo/sandbox/gshell/trunk/gshell-assembly/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-assembly/pom.xml?rev=574416&r1=574415&r2=574416&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-assembly/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-assembly/pom.xml Mon Sep 10 17:49:15 2007
@@ -42,42 +42,47 @@
         <dependency>
             <groupId>org.apache.geronimo.gshell</groupId>
             <artifactId>gshell-bootstrap</artifactId>
-            <version>${pom.version}</version>
+            <version>${version}</version>
         </dependency>
 
         <dependency>
             <groupId>org.apache.geronimo.gshell</groupId>
             <artifactId>gshell-core</artifactId>
-            <version>${pom.version}</version>
+            <version>${version}</version>
         </dependency>
 
         <dependency>
             <groupId>org.apache.geronimo.gshell</groupId>
             <artifactId>gshell-cli</artifactId>
-            <version>${pom.version}</version>
+            <version>${version}</version>
         </dependency>
 
         <dependency>
             <groupId>org.apache.geronimo.gshell.commands</groupId>
             <artifactId>gshell-builtins</artifactId>
-            <version>${pom.version}</version>
+            <version>${version}</version>
         </dependency>
 
         <dependency>
             <groupId>org.apache.geronimo.gshell.commands</groupId>
             <artifactId>gshell-optional</artifactId>
-            <version>${pom.version}</version>
+            <version>${version}</version>
         </dependency>
         
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-log4j12</artifactId>
         </dependency>
-        
+
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>jcl104-over-slf4j</artifactId>
+        </dependency>
+
         <dependency>
             <groupId>org.apache.geronimo.gshell</groupId>
             <artifactId>gshell-diet-log4j</artifactId>
-            <version>${pom.version}</version>
+            <version>${version}</version>
         </dependency>
     </dependencies>
 
@@ -98,7 +103,7 @@
                     <descriptors>
                         <descriptor>${pom.basedir}/src/main/assembly/bin.xml</descriptor>
                     </descriptors>
-                    <finalName>gshell-${pom.version}</finalName>
+                    <finalName>gshell-${version}</finalName>
                 </configuration>
             </plugin>
         </plugins>
@@ -112,7 +117,7 @@
                 <dependency>
                     <groupId>org.apache.geronimo.gshell.commands</groupId>
                     <artifactId>gshell-bsf</artifactId>
-                    <version>${pom.version}</version>
+                    <version>${version}</version>
                 </dependency>
 
                 <dependency>
@@ -124,7 +129,7 @@
                 <dependency>
                     <groupId>org.apache.geronimo.gshell.commands</groupId>
                     <artifactId>gshell-vfs</artifactId>
-                    <version>${pom.version}</version>
+                    <version>${version}</version>
                 </dependency>
             </dependencies>
         </profile>

Modified: geronimo/sandbox/gshell/trunk/gshell-cli/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-cli/pom.xml?rev=574416&r1=574415&r2=574416&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-cli/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-cli/pom.xml Mon Sep 10 17:49:15 2007
@@ -39,21 +39,15 @@
     
     <dependencies>
         <dependency>
-            <groupId>org.apache.geronimo.gshell</groupId>
+            <groupId>org.apache.geronimo.gshell.support</groupId>
             <artifactId>gshell-ansi</artifactId>
-            <version>${pom.version}</version>
+            <version>${version}</version>
         </dependency>
 
         <dependency>
             <groupId>org.apache.geronimo.gshell</groupId>
             <artifactId>gshell-core</artifactId>
-            <version>${pom.version}</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.geronimo.gshell</groupId>
-            <artifactId>gshell-flavor</artifactId>
-            <version>${pom.version}</version>
+            <version>${version}</version>
         </dependency>
 
         <dependency>

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=574416&r1=574415&r2=574416&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 Sep 10 17:49:15 2007
@@ -19,47 +19,35 @@
 
 package org.apache.geronimo.gshell.cli;
 
-import java.io.File;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicReference;
 
-import jline.History;
-import jline.Terminal;
-import org.apache.geronimo.gshell.ErrorNotification;
 import org.apache.geronimo.gshell.ExitNotification;
-import org.apache.geronimo.gshell.Shell;
-import org.apache.geronimo.gshell.ShellSecurityManager;
+import org.apache.geronimo.gshell.GShell;
 import org.apache.geronimo.gshell.ansi.ANSI;
-import org.apache.geronimo.gshell.ansi.Renderer;
+import org.apache.geronimo.gshell.branding.Branding;
 import org.apache.geronimo.gshell.clp.Argument;
 import org.apache.geronimo.gshell.clp.CommandLineProcessor;
 import org.apache.geronimo.gshell.clp.Option;
 import org.apache.geronimo.gshell.clp.Printer;
 import org.apache.geronimo.gshell.command.IO;
-import org.apache.geronimo.gshell.common.StopWatch;
-import org.apache.geronimo.gshell.console.Console;
-import org.apache.geronimo.gshell.console.JLineConsole;
-import org.apache.geronimo.gshell.flavor.Flavor;
 import org.codehaus.plexus.ContainerConfiguration;
 import org.codehaus.plexus.DefaultContainerConfiguration;
 import org.codehaus.plexus.DefaultPlexusContainer;
 import org.codehaus.plexus.PlexusContainer;
 import org.codehaus.plexus.PlexusContainerException;
 import org.codehaus.plexus.classworlds.ClassWorld;
-import org.codehaus.plexus.util.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
- * Command-line interface to bootstrap Shell.
+ * Command-line bootstrap for GShell.
  *
  * @version $Rev$ $Date$
  */
 public class Main
 {
     ///CLOVER:OFF
-    
+
     //
     // NOTE: Do not use logging from this class, as it is used to configure
     //       the logging level with System properties, which will only get
@@ -70,17 +58,6 @@
 
     private final IO io = new IO();
 
-    private final StopWatch watch = new StopWatch(true);
-
-    // Late initialized
-    private Logger log;
-
-    // HACK:
-    private Shell shell;
-    
-    // HACK:
-    private Flavor flavor;
-    
     public Main(final ClassWorld classWorld) {
         assert classWorld != null;
 
@@ -100,6 +77,10 @@
         System.setProperty("gshell.log.console.level", level);
     }
 
+    //
+    // TODO: Add flag to show exception traces
+    //
+    
     @Option(name="-d", aliases={"--debug"}, description="Enable DEBUG logging output")
     private void setDebug(boolean flag) {
         if (flag) {
@@ -114,7 +95,7 @@
             setConsoleLogLevel("INFO");
             io.setVerbosity(IO.Verbosity.VERBOSE);
         }
-    }
+    }                                                 
 
     @Option(name="-q", aliases={"--quiet"}, description="Limit logging output to ERROR")
     private void setQuiet(boolean flag) {
@@ -128,7 +109,7 @@
     private String commands;
 
     @Argument(description="Command")
-    private List<String> args = new ArrayList<String>(0);
+    private List<String> commandArgs = new ArrayList<String>(0);
 
     @Option(name="-D", aliases={"--define"}, metaVar="NAME=VALUE", description="Define system properties")
     private void setSystemProperty(final String nameValue) {
@@ -160,14 +141,14 @@
         type = type.toLowerCase();
 
         if ("unix".equals(type)) {
-            type = jline.UnixTerminal.class.getName();
+            type = "jline.UnixTerminal";
         }
         else if ("win".equals(type) || "windows".equals("type")) {
-            type = jline.WindowsTerminal.class.getName();
+            type = "jline.WindowsTerminal";
         }
         else if ("false".equals(type) || "off".equals(type) || "none".equals(type)) {
-            type = jline.UnsupportedTerminal.class.getName();
-
+            type = "jline.UnsupportedTerminal";
+            
             //
             // HACK: Disable ANSI, for some reason UnsupportedTerminal reports ANSI as enabled, when it shouldn't
             //
@@ -177,99 +158,6 @@
         System.setProperty("jline.terminal", type);
     }
 
-    //
-    // TODO: Add flags to control how the rc/init/profile muck is loaded, and optionally skip it
-    //
-    
-    private void loadScript(final File file) throws Exception {
-        assert file != null;
-        
-        //
-        // FIXME: For some reason the non-command-line version pukes up and an ArrayStoreException in Arguments.shift()
-        //
-
-        // shell.execute("source", file.toURI().toURL());
-
-        shell.execute("source " + file.toURI().toURL());
-
-        //
-        // TODO: Should probably lookup the command by id, since user's might not bind this in the layout
-        //
-    }
-
-    private void loadUserScript(final String fileName) throws Exception {
-        assert fileName != null;
-
-        File file = new File(flavor.getUserDirectory(), fileName);
-
-        if (file.exists()) {
-            log.debug("Loading user-script: {}", file);
-
-            loadScript(file);
-        }
-        else {
-            log.debug("User script is not present: {}", file);
-        }
-    }
-
-    private void loadSharedScript(final String fileName) throws Exception {
-        assert fileName != null;
-
-        File file = new File(flavor.getSharedDirectory(), fileName);
-
-        if (file.exists()) {
-            log.debug("Loading shared-script: {}", file);
-
-            loadScript(file);
-        }
-        else {
-            log.debug("Shared script is not present: {}", file);
-        }
-    }
-
-    private void displayError(final Throwable error) {
-        assert error != null;
-
-        // Decode any error notifications
-        Throwable cause = error;
-        if (error instanceof ErrorNotification) {
-            cause = error.getCause();
-        }
-
-        // Spit out the terse reason why we've failed
-        io.err.print("@|bold,red ERROR| ");
-        io.err.print(cause.getClass().getSimpleName());
-        io.err.println(": @|bold,red " + cause.getMessage() + "|");
-        
-        if (io.isDebug()) {
-            // If we have debug enabled then skip the fancy bits below, and log the full error, don't decode shit
-            log.debug(error.toString(), error);
-        }
-        else if (io.isVerbose()) {
-            // Render a fancy ansi colored stack trace
-            StackTraceElement[] trace = cause.getStackTrace();
-            StringBuffer buff = new StringBuffer();
-
-            for (StackTraceElement e : trace) {
-                buff.append("        @|bold at| ").
-                        append(e.getClassName()).
-                        append(".").
-                        append(e.getMethodName()).
-                        append(" (@|bold ");
-
-                buff.append(e.isNativeMethod() ? "Native Method" :
-                            (e.getFileName() != null && e.getLineNumber() != -1 ? e.getFileName() + ":" + e.getLineNumber() :
-                                (e.getFileName() != null ? e.getFileName() : "Unknown Source")));
-
-                buff.append("|)");
-
-                io.err.println(buff);
-
-                buff.setLength(0);
-            }
-        }
-    }
-
     private PlexusContainer createContainer() throws PlexusContainerException {
         // Boot up the container
         ContainerConfiguration config = new DefaultContainerConfiguration();
@@ -279,155 +167,7 @@
         return new DefaultPlexusContainer(config);
     }
 
-    private int execute(final String[] args) throws Exception {
-        // Its okay to use logging now
-        log = LoggerFactory.getLogger(getClass());
-
-        PlexusContainer container = createContainer();
-
-        //
-        // HACK: Load the flavor here for now
-        //
-        
-        flavor = (Flavor) container.lookup(Flavor.class);
-
-        //
-        // TODO: We need to pass in our I/O context to the container directly
-        //
-        
-        // Load the GShell instance
-        shell = (Shell) container.lookup(Shell.class);
-
-        // Log some information about our terminal
-        Terminal term = Terminal.getTerminal();
-
-        log.debug("Using terminal: {}", term);
-        log.debug("  Supported: {}", term.isSupported());
-        log.debug("  H x W: {} x {}", term.getTerminalHeight(), term.getTerminalWidth());
-        log.debug("  Echo: {}", term.getEcho());
-        log.debug("  ANSI: {} ", term.isANSISupported());
-
-        if (term instanceof jline.WindowsTerminal) {
-            log.debug("  Direct: {}", ((jline.WindowsTerminal)term).getDirectConsole());
-        }
-
-       log.debug("Started in {}", watch);
-
-        int code = 0;
-
-        try {
-            //
-            // TODO: Load gsh.properties if it exists?
-            //
-
-            loadSharedScript(flavor.getProfileScriptName());
-
-            loadUserScript(flavor.getProfileScriptName());
-
-            //
-            // TODO: Pass interactive flags (maybe as property) so gshell knows what modfooe it is
-            //
-
-            Object result = null;
-            
-            if (commands != null) {
-                shell.execute(commands);
-            }
-            else if (interactive) {
-                log.debug("Starting interactive console");
-
-                loadUserScript(flavor.getInteractiveScriptName());
-
-                IO io = shell.getIO();
-
-                Console.Executor executor = new Console.Executor() {
-                    public Result execute(String line) throws Exception {
-                        try {
-                            /* Object result =*/ shell.execute(line);
-                        }
-                        catch (ExitNotification n) {
-                            //
-                            // FIXME: This eats up the exit code we are to use...
-                            //
-
-                            return Result.STOP;
-                        }
-
-                        return Result.CONTINUE;
-                    }
-                };
-
-                JLineConsole runner = new JLineConsole(executor, io);
-
-                runner.setPrompter(new Console.Prompter() {
-                    Renderer renderer = new Renderer();
-
-                    public String prompt() {
-                        return renderer.render("@|bold gsh| > ");
-                    }
-                });
-
-                runner.setErrorHandler(new Console.ErrorHandler() {
-                    public Result handleError(final Throwable error) {
-                        displayError(error);
-                        return Result.CONTINUE;
-                    }
-                });
-
-                runner.setHistory(new History());
-                runner.setHistoryFile(new File(flavor.getUserDirectory(), flavor.getHistoryFileName()));
-                
-                if (!io.isQuiet()) {
-                    io.out.print(flavor.getWelcomeBanner());
-                    
-                    int width = term.getTerminalWidth();
-
-                    // If we can't tell, or have something bogus then use a reasonable default
-                    if (width < 1) {
-                        width = 80;
-                    }
-
-                    io.out.println(StringUtils.repeat("-", width - 1));
-                }
-
-                // Check if there are args, and run them and then enter interactive
-                if (args.length != 0) {
-                    shell.execute(args);
-                }
-                
-                runner.run();
-            }
-            else {
-                result = shell.execute(args);
-            }
-
-            // If the result is a number, then pass that back to the calling shell
-            if (result instanceof Number) {
-                code = ((Number)result).intValue();
-            }
-        }
-        catch (ExitNotification n) {
-            log.debug("Exiting w/code: {}", n.code);
-
-            code = n.code;
-        }
-        catch (Throwable t) {
-            io.err.println("FATAL: " + t);
-            t.printStackTrace(io.err);
-            
-            code = ExitNotification.FATAL_CODE;
-        }
-
-        log.debug("Exiting with code: {}, after running for: {}", code, watch);
-
-        return code;
-    }
-
-    //
-    // Bootstrap
-    //
-
-    public void run(final String[] args) throws Exception {
+    public void boot(final String[] args) throws Exception {
         assert args != null;
 
         // Default is to be quiet
@@ -438,20 +178,21 @@
         clp.process(args);
 
         //
-        // HACK: We need the dang flavor...
+        // HACK: We need the dang branding...
         //
 
+        Branding branding = null;
         if (help || version) {
             PlexusContainer container = createContainer();
-            flavor = (Flavor) container.lookup(Flavor.class);
+            branding = (Branding) container.lookup(Branding.class);
         }
 
         //
         // TODO: Use methods to handle these...
         //
-        
+
         if (help) {
-            io.out.println(System.getProperty("program.name", flavor.getName()) + " [options] <command> [args]");
+            io.out.println(System.getProperty("program.name", branding.getName()) + " [options] <command> [args]");
             io.out.println();
 
             Printer printer = new Printer(clp);
@@ -464,15 +205,16 @@
         }
 
         if (version) {
-            io.out.println(flavor.getVersion());
+            io.out.println(branding.getVersion());
             io.out.println();
             io.out.flush();
 
             System.exit(ExitNotification.DEFAULT_CODE);
         }
 
+        // Setup a refereence for our exit code so our callback thread can tell if we've shutdown normally or not
         final AtomicReference<Integer> codeRef = new AtomicReference<Integer>();
-        int code;
+        int code = ExitNotification.DEFAULT_CODE;
 
         Runtime.getRuntime().addShutdownHook(new Thread("GShell Shutdown Hook") {
             public void run() {
@@ -481,36 +223,45 @@
                     // will set an exit code through the proper channels
 
                     io.err.println();
-                    io.err.println("@|red WARNING:| Abnormal JVM shutdown detected");
+                    io.err.println("WARNING: Abnormal JVM shutdown detected");
                 }
 
                 io.flush();
             }
         });
 
-        // Install the security, keep a hold on the old one
-        final SecurityManager sm = System.getSecurityManager();
-        System.setSecurityManager(new ShellSecurityManager());
-
         try {
-            code = execute(this.args.toArray(new String[this.args.size()]));
-            codeRef.set(code);
+            GShell gshell = new GShell(classWorld, io);
+
+            // clp gives us a list, but we need an array
+            String[] _args = commandArgs.toArray(new String[commandArgs.size()]);
+
+            if (commands != null) {
+                gshell.execute(commands);
+            }
+            else if (interactive) {
+                gshell.run(_args);
+            }
+            else {
+                gshell.execute(_args);
+            }
         }
-        finally {
-            // Reset the security so the below System.exit() won't puke
-            System.setSecurityManager(sm);
+        catch (ExitNotification n) {
+            code = n.code;
         }
-        
+
+        codeRef.set(code);
+
         System.exit(code);
     }
-    
+
     public static void main(final String[] args, final ClassWorld world) throws Exception {
         Main main = new Main(world);
-        main.run(args);
+        main.boot(args);
     }
 
     public static void main(final String[] args) throws Exception {
-        main(args, new ClassWorld("gshell.legacy", Thread.currentThread().getContextClassLoader()));
+        main(args, new ClassWorld("gshell", Thread.currentThread().getContextClassLoader()));
     }
 }
 

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=574416&r1=574415&r2=574416&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 Mon Sep 10 17:49:15 2007
@@ -34,6 +34,22 @@
         </component-discoverers>
     </component-discoverer-manager>
 
+    <!--
+    NOTE: We don't need this to use factories... just leaving here right now as reference.
+    
+    <component-factory-manager implementation="org.codehaus.plexus.component.factory.DefaultComponentFactoryManager">
+        <component-factories>
+            <component-factory implementation="org.apache.geronimo.gshell.lookup.IOLookup">
+                <id>IOLookup</id>
+            </component-factory>
+
+            <component-factory implementation="org.apache.geronimo.gshell.lookup.EnvironmentLookup">
+                <id>EnvironmentLookup</id>
+            </component-factory>
+        </component-factories>
+    </component-factory-manager>
+    -->
+
     <components>
         <!--
         Configure our logging component to be used so Plexus will pick it up.
@@ -54,26 +70,40 @@
         </component>
 
         <!--
-        Hook up the flavor to use.
+        Hook up the branding to use.
         -->
         <component>
-            <role>org.apache.geronimo.gshell.flavor.Flavor</role>
+            <role>org.apache.geronimo.gshell.branding.Branding</role>
             <role-hint>default</role-hint>
-            <implementation>org.apache.geronimo.gshell.flavor.VanillaFlavor</implementation>
+            <implementation>org.apache.geronimo.gshell.branding.DefaultBranding</implementation>
             <requirements>
                 <requirement>
-                    <role>org.apache.geronimo.gshell.flavor.VersionLoader</role>
+                    <role>org.apache.geronimo.gshell.branding.VersionLoader</role>
                 </requirement>
             </requirements>
         </component>
 
         <!--
-        HACK: This is a massive hackinstine just to get things moving along... and will be tossed as soon as a palatable solution crosses my path.
+        Add our instance lookup components.
         -->
-        
+
         <component>
             <role>org.apache.geronimo.gshell.command.IO</role>
-            <implementation>org.apache.geronimo.gshell.command.IO</implementation>
+            <component-factory>IOLookup</component-factory>
+            <instantiation-strategy>per-lookup</instantiation-strategy>
         </component>
+
+        <component>
+            <role>org.apache.geronimo.gshell.shell.Environment</role>
+            <component-factory>EnvironmentLookup</component-factory>
+            <instantiation-strategy>per-lookup</instantiation-strategy>
+        </component>
+        
+        <component>
+            <role>jline.Terminal</role>
+            <component-factory>Terminal</component-factory>
+            <instantiation-strategy>per-lookup</instantiation-strategy>
+        </component>
+
     </components>
 </plexus>

Modified: geronimo/sandbox/gshell/trunk/gshell-command-api/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-command-api/pom.xml?rev=574416&r1=574415&r2=574416&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-command-api/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-command-api/pom.xml Mon Sep 10 17:49:15 2007
@@ -41,31 +41,31 @@
         <dependency>
             <groupId>org.apache.geronimo.gshell.support</groupId>
             <artifactId>gshell-common</artifactId>
-            <version>${pom.version}</version>
+            <version>${version}</version>
         </dependency>
 
         <dependency>
             <groupId>org.apache.geronimo.gshell.support</groupId>
             <artifactId>gshell-ansi</artifactId>
-            <version>${pom.version}</version>
+            <version>${version}</version>
         </dependency>
 
         <dependency>
             <groupId>org.apache.geronimo.gshell.support</groupId>
             <artifactId>gshell-i18n</artifactId>
-            <version>${pom.version}</version>
+            <version>${version}</version>
         </dependency>
         
         <dependency>
             <groupId>org.apache.geronimo.gshell.support</groupId>
             <artifactId>gshell-clp</artifactId>
-            <version>${pom.version}</version>
+            <version>${version}</version>
         </dependency>
 
         <dependency>
             <groupId>org.apache.geronimo.gshell.support</groupId>
             <artifactId>gshell-prefs</artifactId>
-            <version>${pom.version}</version>
+            <version>${version}</version>
         </dependency>
 
         <dependency>

Copied: geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/CommandExecutor.java (from r573981, geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/Shell.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/CommandExecutor.java?p2=geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/CommandExecutor.java&p1=geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/Shell.java&r1=573981&r2=574416&rev=574416&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/Shell.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/CommandExecutor.java Mon Sep 10 17:49:15 2007
@@ -17,25 +17,18 @@
  * under the License.
  */
 
-package org.apache.geronimo.gshell;
-
-import org.apache.geronimo.gshell.command.IO;
-import org.apache.geronimo.gshell.command.Variables;
+package org.apache.geronimo.gshell.command;
 
 /**
- * This is the primary interface to executing named commands.
+ * ???
  *
  * @version $Rev$ $Date$
  */
-public interface Shell
+public interface CommandExecutor
 {
-    IO getIO();
-
-    Variables getVariables();
-    
     Object execute(String line) throws Exception;
-    
+
     Object execute(String command, final Object[] args) throws Exception;
 
     Object execute(Object... args) throws Exception;
-}
+}
\ No newline at end of file

Modified: geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java?rev=574416&r1=574415&r2=574416&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java Mon Sep 10 17:49:15 2007
@@ -23,7 +23,6 @@
 import org.apache.geronimo.gshell.clp.Option;
 import org.apache.geronimo.gshell.clp.Printer;
 import org.apache.geronimo.gshell.common.Arguments;
-import org.apache.geronimo.gshell.common.Notification;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -52,6 +51,10 @@
         this.context = context;
         this.io = context.getIO();
         this.variables = context.getVariables();
+
+        // Re-setup logging using our id
+        String id = context.getCommandDescriptor().getId();
+        log = LoggerFactory.getLogger(getClass().getName() + "." + id);
     }
 
     public Object execute(final Object... args) throws Exception {
@@ -59,54 +62,27 @@
 
         log.info("Executing w/args: [{}]", Arguments.asString(args));
 
-        Object result = null;
-
-        //
-        // TODO: Move this error handling/logging muck up to the shell....
-        //
-        
-        try {
-            CommandLineProcessor clp = new CommandLineProcessor(this);
-            clp.process(Arguments.toStringArray(args));
+        CommandLineProcessor clp = new CommandLineProcessor(this);
+        clp.process(Arguments.toStringArray(args));
 
+        // Handle --help/-h automatically for the command
+        if (displayHelp) {
             //
-            // TODO: Need to mark this option as superceeding other required arguments/options
+            // TODO: Make a special PrinterHandler to abstrat this muck from having to process it by hand
             //
             
-            // Handle --help/-h automatically for the command
-            if (displayHelp) {
-                displayHelp(clp);
-            }
-            else {
-                // Invoke the command's action
-                result = doExecute();
-            }
-        }
-        catch (Exception e) {
-            log.error(e.getMessage());
-            log.debug("Exception details", e);
-
-            result = Command.FAILURE;
-        }
-        catch (Notification n) {
-            // Always re-throw notifications
-            throw n;
+            displayHelp(clp);
+            
+            return SUCCESS;
         }
-        catch (Error e) {
-            log.error(e.getMessage());
-            log.debug("Error details", e);
 
-            result = Command.FAILURE;
-        }
-        
-        log.info("Command exiting with result: {}", result);
+        assert context != null;
+        assert io != null;
+        assert variables != null;
 
-        return result;
+        return doExecute();
     }
 
-    /**
-     * Sub-class should override to perform custom execution.
-     */
     protected abstract Object doExecute() throws Exception;
 
     protected void displayHelp(final CommandLineProcessor clp) {
@@ -115,7 +91,7 @@
         //
         // TODO: Need to ask the LayoutManager what the real name is for our command's ID
         //
-        
+
         io.out.println(context.getCommandDescriptor().getId());
         io.out.println(" -- ");
         io.out.println();

Modified: geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/Variables.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/Variables.java?rev=574416&r1=574415&r2=574416&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/Variables.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/command/Variables.java Mon Sep 10 17:49:15 2007
@@ -22,7 +22,7 @@
 import java.util.Iterator;
 
 /**
- * ???
+ * Provides command instances with nested namespace for storing context.
  *
  * @version $Rev$ $Date$
  */

Added: geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/Environment.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/Environment.java?rev=574416&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/Environment.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/Environment.java Mon Sep 10 17:49:15 2007
@@ -0,0 +1,35 @@
+/*
+ * 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.shell;
+
+import org.apache.geronimo.gshell.command.IO;
+import org.apache.geronimo.gshell.command.Variables;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Environment
+{
+    IO getIO();
+
+    Variables getVariables();
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/Environment.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/Environment.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/Environment.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/InteractiveShell.java (from r573981, geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/Shell.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/InteractiveShell.java?p2=geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/InteractiveShell.java&p1=geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/Shell.java&r1=573981&r2=574416&rev=574416&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/Shell.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/InteractiveShell.java Mon Sep 10 17:49:15 2007
@@ -17,25 +17,15 @@
  * under the License.
  */
 
-package org.apache.geronimo.gshell;
-
-import org.apache.geronimo.gshell.command.IO;
-import org.apache.geronimo.gshell.command.Variables;
+package org.apache.geronimo.gshell.shell;
 
 /**
- * This is the primary interface to executing named commands.
+ * An extention of the {@link Shell} interface for implementations that can be run interactivly.
  *
  * @version $Rev$ $Date$
  */
-public interface Shell
+public interface InteractiveShell
+    extends Shell
 {
-    IO getIO();
-
-    Variables getVariables();
-    
-    Object execute(String line) throws Exception;
-    
-    Object execute(String command, final Object[] args) throws Exception;
-
-    Object execute(Object... args) throws Exception;
-}
+    void run(Object... args) throws Exception;
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/InteractiveShell.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/InteractiveShell.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/InteractiveShell.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/Shell.java (from r573981, geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/Shell.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/Shell.java?p2=geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/Shell.java&p1=geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/Shell.java&r1=573981&r2=574416&rev=574416&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/Shell.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/Shell.java Mon Sep 10 17:49:15 2007
@@ -17,25 +17,19 @@
  * under the License.
  */
 
-package org.apache.geronimo.gshell;
+package org.apache.geronimo.gshell.shell;
 
-import org.apache.geronimo.gshell.command.IO;
-import org.apache.geronimo.gshell.command.Variables;
+import org.apache.geronimo.gshell.command.CommandExecutor;
 
 /**
- * This is the primary interface to executing named commands.
+ * This is the primary interface to executing commands.
  *
  * @version $Rev$ $Date$
  */
 public interface Shell
+    extends CommandExecutor
 {
-    IO getIO();
+    ShellInfo getShellInfo();
 
-    Variables getVariables();
-    
-    Object execute(String line) throws Exception;
-    
-    Object execute(String command, final Object[] args) throws Exception;
-
-    Object execute(Object... args) throws Exception;
+    Environment getEnvironment();
 }

Propchange: geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/Shell.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/Shell.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/Shell.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/ShellInfo.java (from r573981, geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/ShellInfo.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/ShellInfo.java?p2=geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/ShellInfo.java&p1=geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/ShellInfo.java&r1=573981&r2=574416&rev=574416&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/ShellInfo.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/ShellInfo.java Mon Sep 10 17:49:15 2007
@@ -17,9 +17,10 @@
  * under the License.
  */
 
-package org.apache.geronimo.gshell;
+package org.apache.geronimo.gshell.shell;
 
 import java.io.File;
+import java.net.InetAddress;
 
 /**
  * Provides some runtime information about the shell.
@@ -29,4 +30,8 @@
 public interface ShellInfo
 {
     File getHomeDir();
+
+    InetAddress getLocalHost();
+
+    String getUserName();
 }

Propchange: geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/ShellInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/ShellInfo.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/ShellInfo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/package-info.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/package-info.java?rev=574416&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/package-info.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/package-info.java Mon Sep 10 17:49:15 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.
+ */
+
+/**
+ * The basic shell interfaces.
+ *
+ * @version $Rev$ $Date$
+ */
+package org.apache.geronimo.gshell.shell;

Propchange: geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/package-info.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-command-api/src/main/java/org/apache/geronimo/gshell/shell/package-info.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

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=574416&r1=574415&r2=574416&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-bsf/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-bsf/pom.xml Mon Sep 10 17:49:15 2007
@@ -41,13 +41,13 @@
         <dependency>
             <groupId>org.apache.geronimo.gshell</groupId>
             <artifactId>gshell-command-api</artifactId>
-            <version>${pom.version}</version>
+            <version>${version}</version>
         </dependency>
 
         <dependency>
             <groupId>org.apache.geronimo.gshell</groupId>
             <artifactId>gshell-core</artifactId>
-            <version>${pom.version}</version>
+            <version>${version}</version>
         </dependency>
 
         <dependency>
@@ -75,7 +75,7 @@
             <plugin>
                 <groupId>org.apache.geronimo.gshell</groupId>
                 <artifactId>gshell-maven-plugin</artifactId>
-                <version>${pom.version}</version>
+                <version>${version}</version>
                 <executions>
                     <execution>
                         <goals>

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=574416&r1=574415&r2=574416&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/pom.xml Mon Sep 10 17:49:15 2007
@@ -39,21 +39,15 @@
     
     <dependencies>
         <dependency>
-            <groupId>org.apache.geronimo.gshell</groupId>
+            <groupId>org.apache.geronimo.gshell.support</groupId>
             <artifactId>gshell-ansi</artifactId>
-            <version>${pom.version}</version>
+            <version>${version}</version>
         </dependency>
 
         <dependency>
             <groupId>org.apache.geronimo.gshell</groupId>
             <artifactId>gshell-core</artifactId>
-            <version>${pom.version}</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.geronimo.gshell</groupId>
-            <artifactId>gshell-flavor</artifactId>
-            <version>${pom.version}</version>
+            <version>${version}</version>
         </dependency>
     </dependencies>
 
@@ -75,7 +69,7 @@
             <plugin>
                 <groupId>org.apache.geronimo.gshell</groupId>
                 <artifactId>gshell-maven-plugin</artifactId>
-                <version>${pom.version}</version>
+                <version>${version}</version>
                 <executions>
                     <execution>
                         <goals>

Copied: geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/EchoCommand.java (from r573981, 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-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/EchoCommand.java?p2=geronimo/sandbox/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/EchoCommand.java&p1=geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/src/main/java/org/apache/geronimo/gshell/commands/optional/EchoCommand.java&r1=573981&r2=574416&rev=574416&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-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/EchoCommand.java Mon Sep 10 17:49:15 2007
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.geronimo.gshell.commands.optional;
+package org.apache.geronimo.gshell.commands.builtins;
 
 import java.util.List;
 
@@ -59,4 +59,4 @@
 
         return SUCCESS;
     }
-}
+}
\ No newline at end of file

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=574416&r1=574415&r2=574416&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 Mon Sep 10 17:49:15 2007
@@ -26,7 +26,7 @@
 import org.apache.geronimo.gshell.command.CommandSupport;
 import org.apache.geronimo.gshell.command.annotation.CommandComponent;
 import org.apache.geronimo.gshell.command.descriptor.CommandDescriptor;
-import org.apache.geronimo.gshell.flavor.Flavor;
+import org.apache.geronimo.gshell.branding.Branding;
 import org.apache.geronimo.gshell.layout.LayoutManager;
 import org.apache.geronimo.gshell.plugin.PluginCollector;
 import org.codehaus.plexus.component.annotations.Requirement;
@@ -48,7 +48,7 @@
     private LayoutManager layoutManager;
 
     @Requirement
-    private Flavor flavor;
+    private Branding branding;
 
     private Renderer renderer = new Renderer();
 
@@ -57,7 +57,7 @@
         assert layoutManager != null;
 
         io.out.println();
-        io.out.println(flavor.getAbout());
+        io.out.print(branding.getAbout());
         io.out.println();
 
         io.out.println("Available commands:");

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=574416&r1=574415&r2=574416&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 Mon Sep 10 17:49:15 2007
@@ -27,8 +27,8 @@
 import java.net.MalformedURLException;
 import java.net.URL;
 
-import org.apache.geronimo.gshell.Shell;
 import org.apache.geronimo.gshell.clp.Argument;
+import org.apache.geronimo.gshell.command.CommandExecutor;
 import org.apache.geronimo.gshell.command.CommandSupport;
 import org.apache.geronimo.gshell.command.annotation.CommandComponent;
 import org.codehaus.plexus.component.annotations.Requirement;
@@ -43,7 +43,7 @@
     extends CommandSupport
 {
     @Requirement
-    private Shell shell;
+    private CommandExecutor executor;
 
     @Argument(required=true, description="Source file")
     private String source;
@@ -62,7 +62,7 @@
 
         String line;
         while ((line = reader.readLine()) != null) {
-            shell.execute(line);
+            executor.execute(line);
         }
 
         return SUCCESS;

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=574416&r1=574415&r2=574416&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-optional/pom.xml Mon Sep 10 17:49:15 2007
@@ -55,7 +55,7 @@
             <plugin>
                 <groupId>org.apache.geronimo.gshell</groupId>
                 <artifactId>gshell-maven-plugin</artifactId>
-                <version>${pom.version}</version>
+                <version>${version}</version>
                 <executions>
                     <execution>
                         <goals>

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=574416&r1=574415&r2=574416&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 Mon Sep 10 17:49:15 2007
@@ -45,10 +45,6 @@
 
         log.info("Executing: {}", builder.command());
 
-        //
-        // TODO: May need to expose the Process's destroy() if Command abort() is issued?
-        //
-
         Process p = builder.start();
 
         PumpStreamHandler handler = new PumpStreamHandler(io.inputStream, io.outputStream, io.errorStream);

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=574416&r1=574415&r2=574416&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/gshell-vfs/pom.xml Mon Sep 10 17:49:15 2007
@@ -63,7 +63,7 @@
             <plugin>
                 <groupId>org.apache.geronimo.gshell</groupId>
                 <artifactId>gshell-maven-plugin</artifactId>
-                <version>${pom.version}</version>
+                <version>${version}</version>
                 <executions>
                     <execution>
                         <goals>

Modified: geronimo/sandbox/gshell/trunk/gshell-commands/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/pom.xml?rev=574416&r1=574415&r2=574416&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/pom.xml Mon Sep 10 17:49:15 2007
@@ -43,7 +43,7 @@
         <dependency>
             <groupId>org.apache.geronimo.gshell</groupId>
             <artifactId>gshell-command-api</artifactId>
-            <version>${pom.version}</version>
+            <version>${version}</version>
         </dependency>
     </dependencies>
     

Modified: geronimo/sandbox/gshell/trunk/gshell-core/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/pom.xml?rev=574416&r1=574415&r2=574416&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/pom.xml Mon Sep 10 17:49:15 2007
@@ -41,19 +41,13 @@
         <dependency>
             <groupId>org.apache.geronimo.gshell</groupId>
             <artifactId>gshell-command-api</artifactId>
-            <version>${pom.version}</version>
-        </dependency>
-
-        <dependency>
-            <groupId>org.apache.geronimo.gshell</groupId>
-            <artifactId>gshell-flavor</artifactId>
-            <version>${pom.version}</version>
+            <version>${version}</version>
         </dependency>
         
         <dependency>
             <groupId>org.apache.geronimo.gshell</groupId>
             <artifactId>gshell-parser</artifactId>
-            <version>${pom.version}</version>
+            <version>${version}</version>
         </dependency>
 
         <dependency>
@@ -62,11 +56,6 @@
         </dependency>
         
         <dependency>
-            <groupId>org.codehaus.plexus</groupId>
-            <artifactId>plexus-expression-evaluator</artifactId>
-        </dependency>
-
-        <dependency>
             <groupId>com.thoughtworks.xstream</groupId>
             <artifactId>xstream</artifactId>
         </dependency>
@@ -75,15 +64,43 @@
             <groupId>jline</groupId>
             <artifactId>jline</artifactId>
         </dependency>
-        
+
+        <dependency>
+            <groupId>commons-jexl</groupId>
+            <artifactId>commons-jexl</artifactId>
+        </dependency>
+
         <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-simple</artifactId>
             <scope>test</scope>
         </dependency>
+
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>jcl104-over-slf4j</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>
+        <resources>
+            <resource>
+                <directory>${pom.basedir}/src/main/resources</directory>
+                <includes>
+                    <include>**/*</include>
+                </includes>
+            </resource>
+
+            <resource>
+                <directory>${pom.basedir}/src/main/resources</directory>
+                <filtering>true</filtering>
+                <includes>
+                    <include>org/apache/geronimo/gshell/branding/version.properties</include>
+                </includes>
+            </resource>
+        </resources>
+
         <plugins>
             <plugin>
                 <groupId>org.codehaus.plexus</groupId>

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/CommandLineBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/CommandLineBuilder.java?rev=574416&r1=574415&r2=574416&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/CommandLineBuilder.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/CommandLineBuilder.java Mon Sep 10 17:49:15 2007
@@ -22,10 +22,15 @@
 import java.io.Reader;
 import java.io.StringReader;
 
+import org.apache.geronimo.gshell.command.CommandExecutor;
 import org.apache.geronimo.gshell.parser.ASTCommandLine;
 import org.apache.geronimo.gshell.parser.CommandLineParser;
 import org.apache.geronimo.gshell.parser.ParseException;
-import org.codehaus.plexus.evaluator.ExpressionEvaluator;
+import org.apache.geronimo.gshell.shell.Environment;
+import org.apache.geronimo.gshell.expression.ExpressionEvaluator;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -34,25 +39,16 @@
  *
  * @version $Rev$ $Date$
  */
+@Component(role=CommandLineBuilder.class)
 public class CommandLineBuilder
 {
     private Logger log = LoggerFactory.getLogger(getClass());
 
-    private CommandLineParser parser;
-
-    private Shell shell;
-
-    private ExpressionEvaluator evaluator;
-
-    public CommandLineBuilder(final Shell shell, final ExpressionEvaluator evaluator) {
-        assert shell != null;
-        assert evaluator != null;
-
-        this.shell = shell;
-        this.evaluator = evaluator;
-        this.parser = new CommandLineParser();
-    }
+    @Requirement
+    private PlexusContainer container;
 
+    private CommandLineParser parser = new CommandLineParser();
+    
     private ASTCommandLine parse(final String input) throws ParseException {
         assert input != null;
 
@@ -75,13 +71,21 @@
             throw new IllegalArgumentException("Command line is empty");
         }
 
-        final ExecutingVisitor visitor = new ExecutingVisitor(shell, evaluator);
-        final ASTCommandLine root = parse(commandLine);
-        
-        return new CommandLine() {
-            public Object execute() throws Exception {
-                return root.jjtAccept(visitor, null);
-            }
-        };
+        try {
+            CommandExecutor executor = (CommandExecutor) container.lookup(CommandExecutor.class);
+            Environment env = (Environment) container.lookup(Environment.class);
+
+            final ExecutingVisitor visitor = new ExecutingVisitor(executor, env);
+            final ASTCommandLine root = parse(commandLine);
+
+            return new CommandLine() {
+                public Object execute() throws Exception {
+                    return root.jjtAccept(visitor, null);
+                }
+            };
+        }
+        catch (Exception e) {
+            throw new ErrorNotification(e);
+        }
     }
 }

Copied: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultCommandExecutor.java (from r573981, geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShell.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultCommandExecutor.java?p2=geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultCommandExecutor.java&p1=geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShell.java&r1=573981&r2=574416&rev=574416&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShell.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultCommandExecutor.java Mon Sep 10 17:49:15 2007
@@ -19,8 +19,11 @@
 
 package org.apache.geronimo.gshell;
 
+import java.util.UUID;
+
 import org.apache.geronimo.gshell.command.Command;
 import org.apache.geronimo.gshell.command.CommandContext;
+import org.apache.geronimo.gshell.command.CommandExecutor;
 import org.apache.geronimo.gshell.command.CommandNotFoundException;
 import org.apache.geronimo.gshell.command.IO;
 import org.apache.geronimo.gshell.command.Variables;
@@ -28,28 +31,27 @@
 import org.apache.geronimo.gshell.common.Arguments;
 import org.apache.geronimo.gshell.common.StopWatch;
 import org.apache.geronimo.gshell.layout.LayoutManager;
+import org.apache.geronimo.gshell.shell.Environment;
 import org.codehaus.plexus.PlexusContainer;
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.component.annotations.Requirement;
-import org.codehaus.plexus.evaluator.ExpressionEvaluator;
 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 implementation of {@link Shell}.
+ * ???
  *
  * @version $Rev$ $Date$
  */
-@Component(role=Shell.class, hint="default")
-public class DefaultShell
-    implements Shell, Initializable
+@Component(role=CommandExecutor.class, hint="default")
+public class DefaultCommandExecutor
+    implements CommandExecutor, Initializable
 {
     private Logger log = LoggerFactory.getLogger(getClass());
 
-    @Requirement
-    private IO io;
+    public DefaultCommandExecutor() {}
 
     @Requirement
     private PlexusContainer container;
@@ -58,48 +60,71 @@
     private LayoutManager layoutManager;
 
     @Requirement
-    private ExpressionEvaluator evaluator;
-
     private CommandLineBuilder commandLineBuilder;
 
-    private Variables variables = new VariablesImpl();
-
     public void initialize() throws InitializationException {
+        /*
         assert evaluator != null;
-        commandLineBuilder = new CommandLineBuilder(this, evaluator);
-    }
 
-    public Variables getVariables() {
-        return variables;
+        System.err.println("ENV: " + env);
+        
+        commandLineBuilder = new CommandLineBuilder(this, env, evaluator);
+        */
     }
 
-    public IO getIO() {
-        return io;
+    public Object execute(final String line) throws Exception {
+        assert line != null;
+
+        log.info("Executing (String): {}", line);
+
+        try {
+            CommandLine cl = commandLineBuilder.create(line);
+
+            return cl.execute();
+        }
+        catch (ErrorNotification n) {
+            // Decode the error notifiation
+            Throwable cause = n.getCause();
+
+            if (cause instanceof Exception) {
+                throw (Exception)cause;
+            }
+            else if (cause instanceof Error) {
+                throw (Error)cause;
+            }
+            else {
+                // Um, if we get this far, which we probably never will, then just re-toss the notifcation
+                throw n;
+            }
+        }
     }
 
-    public Object execute(final String commandLine) throws Exception {
-        assert commandLine != null;
+    public Object execute(final Object... args) throws Exception {
+        assert args != null;
+        assert args.length > 1;
 
-        log.info("Executing (String): {}", commandLine);
+        log.info("Executing (Object...): [{}]", Arguments.asString(args));
 
-        CommandLine cl = commandLineBuilder.create(commandLine);
-        return cl.execute();
+        return execute(String.valueOf(args[0]), Arguments.shift(args));
     }
 
-    public Object execute(final String commandName, final Object[] args) throws Exception {
-        assert commandName != null;
+    public Object execute(final String path, final Object[] args) throws Exception {
+        assert path != null;
         assert args != null;
 
-        log.info("Executing ({}): [{}]", commandName, Arguments.asString(args));
+        log.info("Executing ({}): [{}]", path, Arguments.asString(args));
 
-        // Look up the command descriptor for the given commandName
-        final CommandDescriptor desc = layoutManager.find(commandName);
+        // Look up the command descriptor for the given path
+        final CommandDescriptor desc = layoutManager.find(path);
         if (desc == null) {
-            throw new CommandNotFoundException(commandName);
+            throw new CommandNotFoundException(path);
         }
 
         // Create a new child container for the invocation and lookup the command instance
-        String realmId = "command-invocation";
+        String realmId = "gshell:" + UUID.randomUUID();
+
+        log.debug("Child container realm: {}", realmId);
+
         final PlexusContainer childContainer = container.createChildContainer(realmId, container.getContainerRealm());
         final Command command = (Command)childContainer.lookup(desc.getRole(), desc.getRoleHint());
 
@@ -107,12 +132,15 @@
         // 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
         //
+        
+        final Environment env = (Environment) container.lookup(Environment.class);
 
         // Setup the command context and pass it to the command instance
-        final Variables vars = new VariablesImpl(getVariables());
         CommandContext context = new CommandContext() {
+            final Variables vars = new VariablesImpl(env.getVariables());
+
             public IO getIO() {
-                return io;
+                return env.getIO();
             }
 
             public Variables getVariables() {
@@ -137,7 +165,7 @@
         finally {
             // Make sure that the commands output has been flushed
             try {
-                io.flush();
+                env.getIO().flush();
             }
             catch (Exception ignore) {}
 
@@ -146,18 +174,5 @@
         }
 
         return result;
-    }
-
-    public Object execute(final Object... args) throws Exception {
-        assert args != null;
-        assert args.length > 1;
-
-        log.info("Executing (Object...): [{}]", Arguments.asString(args));
-
-        //
-        // FIXME: This is broken... :-(
-        //
-        
-        return execute(String.valueOf(args[0]), Arguments.shift(args));
     }
 }



Mime
View raw message