geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r574416 [2/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
Modified: 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/DefaultShell.java?rev=574416&r1=574415&r2=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/DefaultShell.java Mon Sep 10 17:49:15 2007
@@ -19,21 +19,32 @@
 
 package org.apache.geronimo.gshell;
 
-import org.apache.geronimo.gshell.command.Command;
-import org.apache.geronimo.gshell.command.CommandContext;
-import org.apache.geronimo.gshell.command.CommandNotFoundException;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.util.concurrent.atomic.AtomicReference;
+
+import jline.History;
+import jline.Terminal;
+import org.apache.geronimo.gshell.ansi.Renderer;
+import org.apache.geronimo.gshell.command.CommandExecutor;
 import org.apache.geronimo.gshell.command.IO;
 import org.apache.geronimo.gshell.command.Variables;
-import org.apache.geronimo.gshell.command.descriptor.CommandDescriptor;
-import org.apache.geronimo.gshell.common.Arguments;
-import org.apache.geronimo.gshell.common.StopWatch;
-import org.apache.geronimo.gshell.layout.LayoutManager;
-import org.codehaus.plexus.PlexusContainer;
+import org.apache.geronimo.gshell.console.Console;
+import org.apache.geronimo.gshell.console.JLineConsole;
+import org.apache.geronimo.gshell.console.TerminalInfo;
+import org.apache.geronimo.gshell.branding.Branding;
+import org.apache.geronimo.gshell.lookup.EnvironmentLookup;
+import org.apache.geronimo.gshell.shell.Environment;
+import org.apache.geronimo.gshell.shell.InteractiveShell;
+import org.apache.geronimo.gshell.shell.Shell;
+import org.apache.geronimo.gshell.shell.ShellInfo;
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.component.annotations.Requirement;
-import org.codehaus.plexus.evaluator.ExpressionEvaluator;
+import org.codehaus.plexus.component.factory.ComponentFactory;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
+import org.codehaus.plexus.util.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -42,122 +53,309 @@
  *
  * @version $Rev$ $Date$
  */
-@Component(role=Shell.class, hint="default")
+@Component(role=InteractiveShell.class)
 public class DefaultShell
-    implements Shell, Initializable
+    implements InteractiveShell, Initializable
 {
     private Logger log = LoggerFactory.getLogger(getClass());
 
     @Requirement
-    private IO io;
+    private ShellInfo shellInfo;
 
     @Requirement
-    private PlexusContainer container;
+    private Branding branding;
 
     @Requirement
-    private LayoutManager layoutManager;
+    private CommandExecutor executor;
 
     @Requirement
-    private ExpressionEvaluator evaluator;
+    private TerminalInfo termInfo;
 
-    private CommandLineBuilder commandLineBuilder;
+    @Requirement
+    private Terminal terminal;
+    
+    @Requirement(role=ComponentFactory.class, hint="EnvironmentLookup")
+    private EnvironmentLookup envLookup;
+    
+    private Environment env;
 
-    private Variables variables = new VariablesImpl();
+    @Requirement
+    private IO io;
 
-    public void initialize() throws InitializationException {
-        assert evaluator != null;
-        commandLineBuilder = new CommandLineBuilder(this, evaluator);
+    public Environment getEnvironment() {
+        if (env == null) {
+            throw new IllegalStateException();
+        }
+
+        return env;
     }
 
-    public Variables getVariables() {
-        return variables;
+    public ShellInfo getShellInfo() {
+        return shellInfo;
     }
 
-    public IO getIO() {
-        return io;
+    public void initialize() throws InitializationException {
+        //
+        // FIXME: This is kinda icky IMO...
+        //
+        
+        // Setup our environment instance
+        env = new Environment() {
+            final Variables variables = new VariablesImpl();
+
+            public IO getIO() {
+                return io;
+            }
+
+            public Variables getVariables() {
+                return variables;
+            }
+        };
+
+        // And propagate it to others
+        envLookup.set(env);
+        
+        //
+        // FIXME: This won't work as desired, as this shell instance is not yet registered, so if a profile
+        //        tries to run something that needs the shell instance... well, loopsvile.
+        //
+        //        This could be a warning sign that some of this class needs to be split up into smaller bits...
+        //
+        
+        try {
+            loadProfileScripts();
+        }
+        catch (Exception e) {
+            throw new InitializationException(e.getMessage(), e);
+        }
     }
 
-    public Object execute(final String commandLine) throws Exception {
-        assert commandLine != null;
+    //
+    // Command Execution (all delegates)
+    //
+    
+    public Object execute(final String line) throws Exception {
+        return executor.execute(line);
+    }
 
-        log.info("Executing (String): {}", commandLine);
+    public Object execute(final Object... args) throws Exception {
+        return executor.execute((Object[])args);
+    }
 
-        CommandLine cl = commandLineBuilder.create(commandLine);
-        return cl.execute();
+    public Object execute(final String path, final Object[] args) throws Exception {
+        return executor.execute(path, args);
     }
 
-    public Object execute(final String commandName, final Object[] args) throws Exception {
-        assert commandName != null;
+    //
+    // Interactive Shell
+    //
+
+    public void run(final Object... args) throws Exception {
         assert args != null;
 
-        log.info("Executing ({}): [{}]", commandName, Arguments.asString(args));
+        log.debug("Starting interactive console");
 
-        // Look up the command descriptor for the given commandName
-        final CommandDescriptor desc = layoutManager.find(commandName);
-        if (desc == null) {
-            throw new CommandNotFoundException(commandName);
-        }
+        loadUserScript(branding.getInteractiveScriptName());
 
-        // Create a new child container for the invocation and lookup the command instance
-        String realmId = "command-invocation";
-        final PlexusContainer childContainer = container.createChildContainer(realmId, container.getContainerRealm());
-        final Command command = (Command)childContainer.lookup(desc.getRole(), desc.getRoleHint());
+        // Setup 2 final refs to allow our executor to pass stuff back to us
+        final AtomicReference<ExitNotification> exitNotifHolder = new AtomicReference<ExitNotification>();
+        final AtomicReference<Object> lastResultHolder = new AtomicReference<Object>();
+
+        // Whip up a tiny console executor that will execute shell command-lines
+        Console.Executor executor = new Console.Executor() {
+            public Result execute(final String line) throws Exception {
+                assert line != null;
+                
+                try {
+                    Object result = DefaultShell.this.execute(line);
+                    
+                    lastResultHolder.set(result);
+                }
+                catch (ExitNotification n) {
+                    exitNotifHolder.set(n);
+                    
+                    return Result.STOP;
+                }
 
-        //
-        // 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
-        //
+                return Result.CONTINUE;
+            }
+        };
 
-        // Setup the command context and pass it to the command instance
-        final Variables vars = new VariablesImpl(getVariables());
-        CommandContext context = new CommandContext() {
-            public IO getIO() {
-                return io;
+        // Ya, bust out the sexy JLine console baby!
+        JLineConsole console = new JLineConsole(executor, io, terminal);
+
+        // Setup the prompt
+        console.setPrompter(new Console.Prompter() {
+            Renderer renderer = new Renderer();
+
+            public String prompt() {
+                String userName = shellInfo.getUserName();
+                String hostName = shellInfo.getLocalHost().getHostName();
+
+                //
+                // HACK: There is no path... yet ;-)
+                //
+                String path = "/";
+
+                return renderer.render("@|bold " + userName + "|@" + hostName + ":@|bold " + path + "|> ");
             }
+        });
 
-            public Variables getVariables() {
-                return vars;
+        // Delegate errors for display and then continue
+        console.setErrorHandler(new Console.ErrorHandler() {
+            public Result handleError(final Throwable error) {
+                assert error != null;
+
+                displayError(error);
+                
+                return Result.CONTINUE;
             }
+        });
 
-            public CommandDescriptor getCommandDescriptor() {
-                return desc;
+        // Hook up a nice history file (we gotta hold on to the history object at some point so the 'history' command can get to it) 
+        History history = new History();
+        console.setHistory(history);
+        console.setHistoryFile(new File(branding.getUserDirectory(), branding.getHistoryFileName()));
+
+        // Unless the user wants us to shut up, then display a nice welcome banner
+        if (!io.isQuiet()) {
+            io.out.print(branding.getWelcomeBanner());
+
+            // HACK: If we can't tell, or have something bogus then use a reasonable default
+            int width = terminal.getTerminalWidth();
+            if (width < 1) {
+                width = 80;
             }
-        };
-        command.init(context);
 
-        // Setup command timings
-        StopWatch watch = new StopWatch(true);
+            io.out.println(StringUtils.repeat("-", width - 1));
+        }
 
-        Object result;
-        try {
-            result = command.execute(args);
+        // Check if there are args, and run them and then enter interactive
+        if (args.length != 0) {
+            execute(args);
+        }
 
-            log.debug("Command completed with result: {}, after: {}", result, watch);
+        // And then spin up the console and go for a jog
+        console.run();
+
+        // If any exit notification occured while running, then puke it up
+        ExitNotification n = exitNotifHolder.get();
+        if (n != null) {
+            throw n;
+        }
+    }
+
+    //
+    // Error Display
+    //
+
+    private void displayError(final Throwable error) {
+        assert error != null;
+
+        // Decode any error notifications
+        Throwable cause = error;
+        if (error instanceof ErrorNotification) {
+            cause = error.getCause();
         }
-        finally {
-            // Make sure that the commands output has been flushed
-            try {
-                io.flush();
-            }
-            catch (Exception ignore) {}
 
-            // Nuke the child container
-            container.removeChildContainer(realmId);
+        // 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);
 
-        return result;
+                buff.setLength(0);
+            }
+        }
     }
 
-    public Object execute(final Object... args) throws Exception {
-        assert args != null;
-        assert args.length > 1;
+    //
+    // Script Processing
+    //
 
-        log.info("Executing (Object...): [{}]", Arguments.asString(args));
+    private void loadProfileScripts() throws Exception {
+        //
+        // TODO: Load gsh.properties if it exists?
+        //
+
+        // Load profile scripts if they exist
+        loadSharedScript(branding.getProfileScriptName());
+        loadUserScript(branding.getProfileScriptName());
+    }
+
+    private void loadScript(final File file) throws Exception {
+        assert file != null;
 
         //
-        // FIXME: This is broken... :-(
+        // FIXME: Don't use 'source 'for right now, the shell spins out of control
+        //        from plexus component loading :-(
         //
-        
-        return execute(String.valueOf(args[0]), Arguments.shift(args));
+        // execute("source", file.toURI().toURL());
+
+        BufferedReader reader = new BufferedReader(new FileReader(file));
+
+        try {
+            String line;
+
+            while ((line = reader.readLine()) != null) {
+                execute(line);
+            }
+        }
+        finally {
+            reader.close();
+        }
+    }
+
+    private void loadUserScript(final String fileName) throws Exception {
+        assert fileName != null;
+
+        File file = new File(branding.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(branding.getSharedDirectory(), fileName);
+
+        if (file.exists()) {
+            log.debug("Loading shared-script: {}", file);
+
+            loadScript(file);
+        }
+        else {
+            log.debug("Shared script is not present: {}", file);
+        }
     }
 }

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShellInfo.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShellInfo.java?rev=574416&r1=574415&r2=574416&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShellInfo.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultShellInfo.java Mon Sep 10 17:49:15 2007
@@ -21,8 +21,11 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
 
-import org.apache.geronimo.gshell.flavor.Flavor;
+import org.apache.geronimo.gshell.branding.Branding;
+import org.apache.geronimo.gshell.shell.ShellInfo;
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.component.annotations.Requirement;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
@@ -42,8 +45,10 @@
     private final Logger log = LoggerFactory.getLogger(getClass());
 
     @Requirement
-    private Flavor flavor;
-    
+    private Branding branding;
+
+    private InetAddress localHost;
+
     private File homeDir;
 
     public File getHomeDir() {
@@ -54,16 +59,35 @@
         return homeDir;
     }
 
+    public InetAddress getLocalHost() {
+        if (localHost == null) {
+            throw new IllegalStateException();
+        }
+
+        return localHost;
+    }
+
+    public String getUserName() {
+        return System.getProperty("user.name");
+    }
+
     public void initialize() throws InitializationException {
         homeDir = detectHomeDir();
         log.debug("Using home directory: {}", homeDir);
+
+        try {
+            localHost = InetAddress.getLocalHost();
+        }
+        catch (UnknownHostException e) {
+            throw new InitializationException("Unable to determine locahost", e);
+        }
     }
     
     private File detectHomeDir() throws InitializationException {
-        String homePath = flavor.getProperty(Flavor.HOME);
+        String homePath = branding.getProperty(Branding.HOME);
         
         if (homePath == null) {
-            throw new InitializationException("The '" + flavor.getPropertyName(Flavor.HOME) + "' property must be set for the shell to function correctly");
+            throw new InitializationException("The '" + branding.getPropertyName(Branding.HOME) + "' property must be set for the shell to function correctly");
         }
 
         // And now lets resolve this sucker

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ExecutingVisitor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ExecutingVisitor.java?rev=574416&r1=574415&r2=574416&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ExecutingVisitor.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ExecutingVisitor.java Mon Sep 10 17:49:15 2007
@@ -22,7 +22,7 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.geronimo.gshell.command.Variables;
+import org.apache.geronimo.gshell.command.CommandExecutor;
 import org.apache.geronimo.gshell.common.Arguments;
 import org.apache.geronimo.gshell.parser.ASTCommandLine;
 import org.apache.geronimo.gshell.parser.ASTExpression;
@@ -31,9 +31,9 @@
 import org.apache.geronimo.gshell.parser.ASTQuotedString;
 import org.apache.geronimo.gshell.parser.CommandLineParserVisitor;
 import org.apache.geronimo.gshell.parser.SimpleNode;
-import org.codehaus.plexus.evaluator.EvaluatorException;
-import org.codehaus.plexus.evaluator.ExpressionEvaluator;
-import org.codehaus.plexus.evaluator.ExpressionSource;
+import org.apache.geronimo.gshell.shell.Environment;
+import org.apache.geronimo.gshell.expression.JexlExpressionEvaluator;
+import org.apache.geronimo.gshell.expression.ExpressionEvaluator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -47,16 +47,16 @@
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
-    private Shell shell;
+    private Environment env;
+    
+    private CommandExecutor executor;
+
+    public ExecutingVisitor(final CommandExecutor executor, final Environment env) {
+        assert executor != null;
+        assert env != null;
 
-    private ExpressionEvaluator evaluator;
-
-    public ExecutingVisitor(final Shell shell, final ExpressionEvaluator evaluator) {
-        assert shell != null;
-        assert evaluator != null;
-
-        this.shell = shell;
-        this.evaluator = evaluator;
+        this.executor = executor;
+        this.env = env;
     }
 
     public Object visit(final SimpleNode node, final Object data) {
@@ -86,22 +86,18 @@
         List<Object> list = new ArrayList<Object>(node.jjtGetNumChildren());
         node.childrenAccept(this, list);
 
-        Object[] args = (Object[])list.toArray(new Object[list.size()]);
+        Object[] args = list.toArray(new Object[list.size()]);
         assert list.size() >= 1;
 
-        String commandName = String.valueOf(args[0]);
+        String path = String.valueOf(args[0]);
         args = Arguments.shift(args);
 
-        Object result;
-
         try {
-            result = shell.execute(commandName, args);
+            return executor.execute(path, args);
         }
         catch (Exception e) {
-            throw new ErrorNotification(e);
+            throw new ErrorNotification("Shell execution failed; path=" + path + "; args=" + Arguments.asString(args), e);
         }
-
-        return result;
     }
 
     private Object appendString(final String value, final Object data) {
@@ -114,41 +110,17 @@
         return value;
     }
 
-    //
-    // TODO: Include parsed ${...} strings?
-    //
-
     private String evaluate(final String expr) {
-        final Variables vars = shell.getVariables();
-
-        ExpressionSource source = new ExpressionSource() {
-            public String getExpressionValue(String expr) {
-                Object value = vars.get(expr);
-                if (value != null) {
-                    return String.valueOf(value);
-                }
-
-                return null;
-            }
-        };
+        assert expr != null;
+        
+        ExpressionEvaluator evaluator = new JexlExpressionEvaluator(env.getVariables());
 
-        evaluator.addExpressionSource(source);
-
-        String value = null;
         try {
-            value = evaluator.expand(expr);
-        }
-        catch (EvaluatorException e) {
-            //
-            // HACK: Just make it work...
-            //
-            throw new RuntimeException(e);
+            return evaluator.parse(expr);
         }
-        finally {
-            evaluator.removeExpressionSource(source);
+        catch (Exception e) {
+            throw new ErrorNotification("Failed to evaluate expression: " + expr, e);
         }
-
-        return value;
     }
 
     public Object visit(final ASTQuotedString node, final Object data) {

Copied: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/GShell.java (from r573981, geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/CommandLine.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/GShell.java?p2=geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/GShell.java&p1=geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/CommandLine.java&r1=573981&r2=574416&rev=574416&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/CommandLine.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/GShell.java Mon Sep 10 17:49:15 2007
@@ -19,22 +19,137 @@
 
 package org.apache.geronimo.gshell;
 
+import java.util.Map;
+
+import org.apache.geronimo.gshell.command.IO;
+import org.apache.geronimo.gshell.lookup.IOLookup;
+import org.apache.geronimo.gshell.shell.Environment;
+import org.apache.geronimo.gshell.shell.InteractiveShell;
+import org.apache.geronimo.gshell.shell.ShellInfo;
+import org.codehaus.plexus.ContainerConfiguration;
+import org.codehaus.plexus.DefaultContainerConfiguration;
+import org.codehaus.plexus.DefaultPlexusContainer;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.classworlds.ClassWorld;
+import org.codehaus.plexus.component.factory.ComponentFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 /**
- * A abstraction of an executable command-line.
- *
- * <p>
- * Could be a simple command or a complex command pipe-line.
+ * A simple facade over GShell, sets up the container for you... you just run commands :-)
  *
  * @version $Rev$ $Date$
  */
-public interface CommandLine
+public class GShell
+    implements InteractiveShell
 {
-    /**
-     * Execute the command-line.
-     *
-     * @return  The final result of the command-line.
-     *
-     * @throws Exception    Failed to execute command-line.
-     */
-    Object execute() throws Exception;
-}
+    private Logger log = LoggerFactory.getLogger(getClass());
+
+    private final ClassWorld classWorld;
+
+    private final IO io;
+    
+    private final PlexusContainer container;
+
+    private final SecurityManager sm;
+
+    private final InteractiveShell shell;
+
+    public GShell(final IO io) throws Exception {
+        this(new ClassWorld("gshell", Thread.currentThread().getContextClassLoader()), io);
+    }
+
+    public GShell(final ClassWorld classWorld, final IO io) throws Exception {
+        assert classWorld != null;
+        assert io != null;
+
+        this.classWorld = classWorld;
+        this.io = io;
+
+        log.debug("Initializing");
+
+        sm = new ShellSecurityManager();
+
+        SecurityManager psm = System.getSecurityManager();
+        System.setSecurityManager(sm);
+
+        try {
+            ContainerConfiguration config = new DefaultContainerConfiguration();
+            config.setName("gshell.core");
+            config.setClassWorld(classWorld);
+            container = new DefaultPlexusContainer(config);
+
+            // We first need to stuff in the IO context for the new shell instance
+            IOLookup lookup = (IOLookup) container.lookup(ComponentFactory.class, IOLookup.class.getSimpleName());
+            lookup.set(io);
+
+            // Then look up the shell we are gonna delegate to
+            shell = (InteractiveShell) container.lookup(InteractiveShell.class);
+
+            // And then do some setup ski
+            Map<String,String> env = System.getenv();
+            shell.getEnvironment().getVariables().set("env", env);
+        }
+        finally {
+            System.setSecurityManager(psm);
+        }
+
+        log.debug("Initialized");
+    }
+
+    public ShellInfo getShellInfo() {
+        return shell.getShellInfo();
+    }
+
+    public Environment getEnvironment() {
+        return shell.getEnvironment();
+    }
+
+    public Object execute(final String line) throws Exception {
+        SecurityManager psm = System.getSecurityManager();
+        System.setSecurityManager(sm);
+
+        try {
+            return shell.execute(line);
+        }
+        finally {
+            System.setSecurityManager(psm);
+        }
+    }
+
+    public Object execute(final Object... args) throws Exception {
+        SecurityManager psm = System.getSecurityManager();
+        System.setSecurityManager(sm);
+
+        try {
+            return shell.execute((Object[])args);
+        }
+        finally {
+            System.setSecurityManager(psm);
+        }
+    }
+
+    public Object execute(final String path, final Object[] args) throws Exception {
+        SecurityManager psm = System.getSecurityManager();
+        System.setSecurityManager(sm);
+
+        try {
+            return shell.execute(path, args);
+        }
+        finally {
+            System.setSecurityManager(psm);
+        }
+    }
+    
+    public void run(final Object... args) throws Exception {
+        SecurityManager psm = System.getSecurityManager();
+        System.setSecurityManager(sm);
+
+        try {
+            shell.run(args);
+        }
+        finally {
+            System.setSecurityManager(psm);
+        }
+    }
+}
\ No newline at end of file

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ShellSecurityManager.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ShellSecurityManager.java?rev=574416&r1=574415&r2=574416&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ShellSecurityManager.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ShellSecurityManager.java Mon Sep 10 17:49:15 2007
@@ -48,8 +48,6 @@
     }
 
     public void checkExit(final int code) {
-        super.checkExit(code);
-
         throw new SecurityException("Use of System.exit() if forbidden!");
     }
 

Copied: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/Branding.java (from r573981, geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/Flavor.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/Branding.java?p2=geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/Branding.java&p1=geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/Flavor.java&r1=573981&r2=574416&rev=574416&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/Flavor.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/Branding.java Mon Sep 10 17:49:15 2007
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.geronimo.gshell.flavor;
+package org.apache.geronimo.gshell.branding;
 
 import java.io.File;
 
@@ -26,7 +26,7 @@
  *
  * @version $Rev$ $Date$
  */
-public interface Flavor
+public interface Branding
 {
     String HOME = "home";
 

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/Branding.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/Branding.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/Branding.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/DefaultBranding.java (from r573981, geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/VanillaFlavor.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/DefaultBranding.java?p2=geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/DefaultBranding.java&p1=geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/VanillaFlavor.java&r1=573981&r2=574416&rev=574416&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/VanillaFlavor.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/DefaultBranding.java Mon Sep 10 17:49:15 2007
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.geronimo.gshell.flavor;
+package org.apache.geronimo.gshell.branding;
 
 import java.io.File;
 import java.io.PrintWriter;
@@ -27,13 +27,13 @@
 import org.codehaus.plexus.component.annotations.Requirement;
 
 /**
- * Provides the <em>vanilla</em> flavor for GShell.
+ * Provides the default branding for GShell.
  *
  * @version $Rev$ $Date$
  */
-@Component(role=Flavor.class, hint="vanilla")
-public class VanillaFlavor
-    implements Flavor
+@Component(role=Branding.class)
+public class DefaultBranding
+    implements Branding
 {
     @Requirement
     private VersionLoader versionLoader;
@@ -93,7 +93,7 @@
         out.println();
         out.println(" @|bold GShell| (" + getVersion() + ")");
         out.println();
-        out.println("Type '@|bold help|' for help.");
+        out.println("Type '@|bold help|' for more information.");
         out.flush();
 
         return writer.toString();

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/DefaultBranding.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/DefaultBranding.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/DefaultBranding.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/PropertiesVersionLoader.java (from r573981, geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/PropertiesVersionLoader.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/PropertiesVersionLoader.java?p2=geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/PropertiesVersionLoader.java&p1=geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/PropertiesVersionLoader.java&r1=573981&r2=574416&rev=574416&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/PropertiesVersionLoader.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/PropertiesVersionLoader.java Mon Sep 10 17:49:15 2007
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.geronimo.gshell.flavor;
+package org.apache.geronimo.gshell.branding;
 
 import java.io.IOException;
 import java.io.InputStream;

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/PropertiesVersionLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/PropertiesVersionLoader.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/PropertiesVersionLoader.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/VersionLoader.java (from r573981, geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/VersionLoader.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/VersionLoader.java?p2=geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/VersionLoader.java&p1=geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/VersionLoader.java&r1=573981&r2=574416&rev=574416&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/java/org/apache/geronimo/gshell/flavor/VersionLoader.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/VersionLoader.java Mon Sep 10 17:49:15 2007
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.apache.geronimo.gshell.flavor;
+package org.apache.geronimo.gshell.branding;
 
 /**
  * Provides a simple interface for loading a version identifier.

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/VersionLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/VersionLoader.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/VersionLoader.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/package-info.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/package-info.java?rev=574416&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/package-info.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/branding/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.
+ */
+
+/**
+ * Provides muck for branding a GShell application.
+ *
+ * @version $Rev$ $Date$
+ */
+package org.apache.geronimo.gshell.branding;
\ No newline at end of file

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

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

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

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/JLineConsole.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/JLineConsole.java?rev=574416&r1=574415&r2=574416&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/JLineConsole.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/JLineConsole.java Mon Sep 10 17:49:15 2007
@@ -25,8 +25,9 @@
 
 import jline.ConsoleReader;
 import jline.History;
-import org.apache.geronimo.gshell.Shell;
+import jline.Terminal;
 import org.apache.geronimo.gshell.command.IO;
+import org.apache.geronimo.gshell.shell.Shell;
 
 /**
  * Support for running a {@link Shell} using the <a href="http://jline.sf.net">JLine</a> library.
@@ -40,17 +41,14 @@
 
     // final CommandsMultiCompletor completor
 
-    //
-    // TODO: Pass in the terminal instance to be used
-    //
-    
-    public JLineConsole(final Executor executor, final IO io) throws IOException {
+    public JLineConsole(final Executor executor, final IO io, final Terminal terminal) throws IOException {
         super(executor);
 
         assert io != null;
 
-        this.reader = new ConsoleReader(io.inputStream, new PrintWriter(io.outputStream, true));
-
+        reader = new ConsoleReader(io.inputStream, new PrintWriter(io.outputStream, true), /*bindings*/null, terminal);
+        reader.setUsePagination(true);
+        
         // this.completor = new CommandsMultiCompletor()
 
         // reader.addCompletor(completor)

Added: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/TerminalFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/TerminalFactory.java?rev=574416&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/TerminalFactory.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/TerminalFactory.java Mon Sep 10 17:49:15 2007
@@ -0,0 +1,43 @@
+/*
+ * 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.console;
+
+import jline.Terminal;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.classworlds.realm.ClassRealm;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.factory.AbstractComponentFactory;
+import org.codehaus.plexus.component.factory.ComponentFactory;
+import org.codehaus.plexus.component.factory.ComponentInstantiationException;
+import org.codehaus.plexus.component.repository.ComponentDescriptor;
+
+/**
+ * Factory for producing {@link Terminal} instances.
+ *
+ * @version $Rev$ $Date$
+ */
+@Component(role=ComponentFactory.class, hint="Terminal")
+public class TerminalFactory
+    extends AbstractComponentFactory
+{
+    public Object newInstance(ComponentDescriptor d, ClassRealm cr, PlexusContainer c) throws ComponentInstantiationException {
+        return Terminal.getTerminal();
+    }
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/TerminalFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/TerminalFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/TerminalFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/TerminalInfo.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/TerminalInfo.java?rev=574416&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/TerminalInfo.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/TerminalInfo.java Mon Sep 10 17:49:15 2007
@@ -0,0 +1,55 @@
+/*
+ * 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.console;
+
+import jline.Terminal;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.Requirement;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * ???
+ *
+ * @version $Rev$ $Date$
+ */
+@Component(role=TerminalInfo.class)
+public class TerminalInfo
+    implements Initializable
+{
+    private Logger log = LoggerFactory.getLogger(getClass());
+
+    @Requirement
+    private Terminal terminal;
+
+    public void initialize() throws InitializationException {
+        log.debug("Using terminal: {}", terminal);
+        log.debug("  Supported: {}", terminal.isSupported());
+        log.debug("  H x W: {} x {}", terminal.getTerminalHeight(), terminal.getTerminalWidth());
+        log.debug("  Echo: {}", terminal.getEcho());
+        log.debug("  ANSI: {} ", terminal.isANSISupported());
+
+        if (terminal instanceof jline.WindowsTerminal) {
+            log.debug("  Direct: {}", ((jline.WindowsTerminal)terminal).getDirectConsole());
+        }
+    }
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/TerminalInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/TerminalInfo.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/TerminalInfo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/expression/ExpressionEvaluator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/expression/ExpressionEvaluator.java?rev=574416&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/expression/ExpressionEvaluator.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/expression/ExpressionEvaluator.java Mon Sep 10 17:49:15 2007
@@ -0,0 +1,49 @@
+/*
+ * 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.expression;
+
+/**
+ * A very simple expression evalutator interface.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ExpressionEvaluator
+{
+    Object evaluate(String expression) throws Exception;
+
+    String parse(String input) throws SyntaxException;
+
+    /**
+     * Thrown to indicate a syntax error while parsing.
+     */
+    public static class SyntaxException
+        extends RuntimeException
+    {
+        ///CLOVER:OFF
+
+        public SyntaxException(final String msg) {
+            super(msg);
+        }
+
+        public SyntaxException(final String msg, final Throwable cause) {
+            super(msg, cause);
+        }
+    }
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/expression/ExpressionEvaluator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/expression/ExpressionEvaluator.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/expression/ExpressionEvaluator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/expression/JexlExpressionEvaluator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/expression/JexlExpressionEvaluator.java?rev=574416&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/expression/JexlExpressionEvaluator.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/expression/JexlExpressionEvaluator.java Mon Sep 10 17:49:15 2007
@@ -0,0 +1,194 @@
+/*
+ * 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.expression;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.commons.jexl.Expression;
+import org.apache.commons.jexl.ExpressionFactory;
+import org.apache.commons.jexl.JexlContext;
+import org.apache.commons.jexl.JexlHelper;
+import org.apache.commons.jexl.resolver.FlatResolver;
+import org.apache.geronimo.gshell.command.Variables;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A very simple expression evalutator using Jexl to do the hard work.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JexlExpressionEvaluator
+    implements ExpressionEvaluator
+{
+    private Logger log = LoggerFactory.getLogger(getClass());
+
+    //
+    // NOTE: May want to add the ${...} bits the the CommandLineParser directly.
+    //       This sub-parser is probably only short-term so we can get soemthing working
+    //
+
+    private final JexlContext context;
+
+    public JexlExpressionEvaluator(final Map vars) {
+        assert vars != null;
+
+        context = JexlHelper.createContext();
+        context.setVars(vars);
+
+
+        log.trace("Using variables: {}", context.getVars());
+    }
+
+    private static Map convertToMap(final Variables vars) {
+        assert vars != null;
+
+        Map<String,Object> map = new HashMap<String,Object>();
+        Iterator<String> iter = vars.names();
+
+        while (iter.hasNext()) {
+            String name = iter.next();
+            map.put(name, vars.get(name));
+        }
+
+        return map;
+    }
+
+    public JexlExpressionEvaluator(final Variables vars) {
+        this(convertToMap(vars));
+    }
+
+    public Map getVariables() {
+        return context.getVars();
+    }
+
+    private final FlatResolver resolver = new FlatResolver(true);
+
+    protected Expression createExpression(final String expression) throws Exception {
+        assert expression != null;
+
+        Expression expr = ExpressionFactory.createExpression(expression);
+        expr.addPreResolver(resolver);
+
+        return expr;
+    }
+
+    public Object evaluate(final String expression) throws Exception {
+        assert expression != null;
+
+        log.debug("Evaluating expression: {}", expression);
+
+        Expression expr = createExpression(expression);
+        
+        Object result = expr.evaluate(context);
+
+        log.debug("Result: {}", result);
+
+        return result;
+    }
+
+    public String parse(final String input) throws SyntaxException {
+        assert input != null;
+
+        log.trace("Parsing input: {}", input);
+
+        StringBuffer buff = new StringBuffer();
+
+        int current = 0;
+
+        while (current < input.length()) {
+            boolean complex = false;
+
+            int start = input.indexOf("$", current);
+
+            if (start == -1) {
+                break;
+            }
+            else if (start + 1 < input.length()) {
+                if (input.charAt(start + 1) == '{') {
+                    complex = true;
+                }
+            }
+
+            int end;
+            if (complex) {
+                end = input.indexOf("}", start);
+                if (end == -1) {
+                    throw new SyntaxException("Missing '}': " + input);
+                }
+            }
+            else {
+                end = input.indexOf(" ", start);
+                if (end == -1) {
+                    end = input.indexOf("\t", start);
+
+                    if (end == -1) {
+                        end = input.length();
+                    }
+                }
+            }
+
+            String expr = input.substring(start + (complex ? 2 : 1), end);
+
+            // System.err.println("b: " + buff);
+            String tmp = input.substring(current, start);
+            // System.err.println("t: " + tmp + "<");
+            buff.append(tmp);
+
+            try {
+                buff.append(evaluate(expr));
+            }
+            catch (Exception e) {
+                throw new SyntaxException("Failed to evaluate: " + expr, e);
+            }
+
+            // System.err.println("s:" + start);
+            // System.err.println("e:" + end);
+            // System.err.println("c:" + current);
+
+            current = end + (complex ? 1 : 0);
+        }
+
+        // System.err.println("c:" + current);
+
+        if (current < input.length()) {
+            // System.err.println("b: " + buff);
+            String tmp = input.substring(current);
+            // System.err.println("t: " + tmp);
+            buff.append(tmp);
+        }
+
+        log.trace("Parsed result: {}", buff);
+
+        return buff.toString();
+    }
+
+    public String parse(final String input, final boolean trim) throws SyntaxException {
+        String output = parse(input);
+        if (trim && output != null) {
+            output = output.trim();
+        }
+
+        return output;
+    }
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/expression/JexlExpressionEvaluator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/expression/JexlExpressionEvaluator.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/expression/JexlExpressionEvaluator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/expression/package-info.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/expression/package-info.java?rev=574416&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/expression/package-info.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/expression/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.
+ */
+
+/**
+ * Simple expression evalutation muck.
+ *
+ * @version $Rev$ $Date$
+ */
+package org.apache.geronimo.gshell.expression;

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

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

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

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/loader/XMLLayoutLoader.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/loader/XMLLayoutLoader.java?rev=574416&r1=574415&r2=574416&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/loader/XMLLayoutLoader.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/layout/loader/XMLLayoutLoader.java Mon Sep 10 17:49:15 2007
@@ -25,8 +25,8 @@
 import java.net.MalformedURLException;
 import java.net.URL;
 
-import org.apache.geronimo.gshell.ShellInfo;
 import org.apache.geronimo.gshell.layout.model.Layout;
+import org.apache.geronimo.gshell.shell.ShellInfo;
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.component.annotations.Requirement;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;

Added: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/lookup/EnvironmentLookup.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/lookup/EnvironmentLookup.java?rev=574416&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/lookup/EnvironmentLookup.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/lookup/EnvironmentLookup.java Mon Sep 10 17:49:15 2007
@@ -0,0 +1,37 @@
+/*
+ * 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.lookup;
+
+import org.apache.geronimo.gshell.shell.Shell;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.InstantiationStrategy;
+import org.codehaus.plexus.component.factory.ComponentFactory;
+
+/**
+ * Lookup factory for {@link Shell.Environment} instances.
+ *
+ * @version $Rev$ $Date$
+ */
+@Component(role=ComponentFactory.class, hint="EnvironmentLookup", instantiationStrategy=InstantiationStrategy.SINGLETON)
+public class EnvironmentLookup
+    extends LookupFactorySupport
+{
+    // empty
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/lookup/EnvironmentLookup.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/lookup/EnvironmentLookup.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/lookup/EnvironmentLookup.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/lookup/IOLookup.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/lookup/IOLookup.java?rev=574416&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/lookup/IOLookup.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/lookup/IOLookup.java Mon Sep 10 17:49:15 2007
@@ -0,0 +1,37 @@
+/*
+ * 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.lookup;
+
+import org.apache.geronimo.gshell.command.IO;
+import org.codehaus.plexus.component.annotations.Component;
+import org.codehaus.plexus.component.annotations.InstantiationStrategy;
+import org.codehaus.plexus.component.factory.ComponentFactory;
+
+/**
+ * Lookup factory for {@link IO} instances.
+ *
+ * @version $Rev$ $Date$
+ */
+@Component(role=ComponentFactory.class, hint="IOLookup", instantiationStrategy=InstantiationStrategy.SINGLETON)
+public class IOLookup
+    extends LookupFactorySupport
+{
+    // empty
+}

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/lookup/IOLookup.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/lookup/IOLookup.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/lookup/IOLookup.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/lookup/LookupFactorySupport.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/lookup/LookupFactorySupport.java?rev=574416&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/lookup/LookupFactorySupport.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/lookup/LookupFactorySupport.java Mon Sep 10 17:49:15 2007
@@ -0,0 +1,73 @@
+/*
+ * 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.lookup;
+
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.classworlds.realm.ClassRealm;
+import org.codehaus.plexus.component.factory.AbstractComponentFactory;
+import org.codehaus.plexus.component.factory.ComponentInstantiationException;
+import org.codehaus.plexus.component.repository.ComponentDescriptor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Support for lookup factory implementations.
+ *
+ * @version $Rev$ $Date$
+ */
+public class LookupFactorySupport
+    extends AbstractComponentFactory
+{
+    protected Logger log = LoggerFactory.getLogger(getClass());
+
+    protected final ThreadLocal holder = new ThreadLocal();
+
+    public synchronized void set(final Object obj) {
+        if (obj == null) {
+            throw new IllegalArgumentException("Instance can not be null");
+        }
+
+        Object prev = get();
+        if (prev == null) {
+            log.debug("Registered instance: {}", obj);
+        }
+        else {
+            log.debug("Replacing previous instance with: {}", obj);
+        }
+        
+        holder.set(obj);
+    }
+
+    public synchronized Object get() {
+        return holder.get();
+    }
+
+    public Object newInstance(ComponentDescriptor descriptor, ClassRealm classRealm, PlexusContainer container) throws ComponentInstantiationException {
+        Object obj = get();
+
+        if (obj == null) {
+            throw new IllegalStateException("Instance not registered");
+        }
+        
+        log.debug("Handing out: {}", obj);
+
+        return obj;
+    }
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/lookup/LookupFactorySupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/lookup/LookupFactorySupport.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/lookup/LookupFactorySupport.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/lookup/package-info.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/lookup/package-info.java?rev=574416&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/lookup/package-info.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/lookup/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.
+ */
+
+/**
+ * Component factory lookup muck.
+ *
+ * @version $Rev$ $Date$
+ */
+package org.apache.geronimo.gshell.lookup;

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

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

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

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/mdo/layout.mdo
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/mdo/layout.mdo?rev=574416&r1=574415&r2=574416&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/mdo/layout.mdo (original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/mdo/layout.mdo Mon Sep 10 17:49:15 2007
@@ -126,13 +126,11 @@
             <name>Command</name>
             <superClass>Node</superClass>
             <version>1.0.0+</version>
-            <description>TODO</description>
             <fields>
                 <field>
                     <name>j</name>
                     <alias>className</alias>
                     <version>1.0.0+</version>
-                    <description>TODO</description>
                     <type>String</type>
                     <required>true</required>
                 </field>
@@ -143,12 +141,10 @@
             <name>Alias</name>
             <superClass>Node</superClass>
             <version>1.0.0+</version>
-            <description>TODO</description>
             <fields>
                 <field>
                     <name>command</name>
                     <version>1.0.0+</version>
-                    <description>TODO</description>
                     <type>String</type>
                     <required>true</required>
                 </field>

Copied: geronimo/sandbox/gshell/trunk/gshell-core/src/main/resources/org/apache/geronimo/gshell/branding/version.properties (from r573981, geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/resources/org/apache/geronimo/gshell/flavor/version.properties)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/resources/org/apache/geronimo/gshell/branding/version.properties?p2=geronimo/sandbox/gshell/trunk/gshell-core/src/main/resources/org/apache/geronimo/gshell/branding/version.properties&p1=geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/resources/org/apache/geronimo/gshell/flavor/version.properties&r1=573981&r2=574416&rev=574416&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-flavor/src/main/resources/org/apache/geronimo/gshell/flavor/version.properties (original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/resources/org/apache/geronimo/gshell/branding/version.properties Mon Sep 10 17:49:15 2007
@@ -21,4 +21,4 @@
 ## $Rev$ $Date$
 ##
 
-version=${pom.version}
+version=${version}

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/resources/org/apache/geronimo/gshell/branding/version.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/resources/org/apache/geronimo/gshell/branding/version.properties
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/resources/org/apache/geronimo/gshell/branding/version.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/expression/JexlExpressionEvaluatorTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/expression/JexlExpressionEvaluatorTest.java?rev=574416&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/expression/JexlExpressionEvaluatorTest.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/expression/JexlExpressionEvaluatorTest.java Mon Sep 10 17:49:15 2007
@@ -0,0 +1,102 @@
+/*
+ * 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.expression;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for the {@link JexlExpressionEvaluator} class.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JexlExpressionEvaluatorTest
+    extends TestCase
+{
+    protected JexlExpressionEvaluator evaluator;
+
+    protected void setUp() throws Exception {
+        evaluator = new JexlExpressionEvaluator(System.getProperties());
+    }
+
+    protected void tearDown() throws Exception {
+        evaluator = null;
+    }
+
+    public void testComplexDefault() throws Exception {
+        String value = "${java.home}";
+        String result = evaluator.parse(value);
+        assertEquals(System.getProperty("java.home"), result);
+    }
+
+    public void testComplexSubst() throws Exception {
+        String value = "BEFORE${java.home}AFTER";
+        String result = evaluator.parse(value);
+        assertEquals("BEFORE" + System.getProperty("java.home") + "AFTER", result);
+    }
+
+    public void testComplexVariable() throws Exception {
+        String myvar = "this is my variable";
+        evaluator.getVariables().put("my.var", myvar);
+
+        String value = "${my.var}";
+        String result = evaluator.parse(value);
+        assertEquals(myvar, result);
+    }
+
+    public void testComplexFlatVariable() throws Exception {
+        String myvar = "this is my variable";
+        evaluator.getVariables().put("my.var", myvar);
+        evaluator.getVariables().put("my", "not used");
+
+        String value = "${my.var}";
+        String result = evaluator.parse(value);
+        assertEquals(myvar, result);
+    }
+
+    public void testComplexSyntaxError() throws Exception {
+        String value = "${java.home";
+
+        try {
+            String result = evaluator.parse(value);
+            fail("Should have thrown an exception");
+        }
+        catch (ExpressionEvaluator.SyntaxException expected) {
+            // ignore
+        }
+    }
+
+    public void testSimple() throws Exception {
+        String value = "$java.home";
+        String result = evaluator.parse(value);
+        assertEquals(System.getProperty("java.home"), result);
+    }
+
+    public void testSimpleSubst() throws Exception {
+        String value = "BEFORE$java.home AFTER";
+        String result = evaluator.parse(value);
+        assertEquals("BEFORE" + System.getProperty("java.home") + " AFTER", result);
+    }
+
+    public void testSimpleSubst2() throws Exception {
+        String value = "BEFORE$java.home\tAFTER";
+        String result = evaluator.parse(value);
+        assertEquals("BEFORE" + System.getProperty("java.home") + "\tAFTER", result);
+    }
+}
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/expression/JexlExpressionEvaluatorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/expression/JexlExpressionEvaluatorTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/expression/JexlExpressionEvaluatorTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

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

Modified: geronimo/sandbox/gshell/trunk/gshell-parser/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-parser/pom.xml?rev=574416&r1=574415&r2=574416&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-parser/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-parser/pom.xml Mon Sep 10 17:49:15 2007
@@ -100,7 +100,7 @@
             <plugin>
                 <groupId>org.apache.geronimo.gshell</groupId>
                 <artifactId>javacc-maven-plugin</artifactId>
-                <version>${pom.version}</version>
+                <version>${version}</version>
                 <executions>
                     <execution>
                         <id>jjtree</id>

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

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

Modified: geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/Arguments.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/Arguments.java?rev=574416&r1=574415&r2=574416&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/Arguments.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/main/java/org/apache/geronimo/gshell/common/Arguments.java Mon Sep 10 17:49:15 2007
@@ -19,6 +19,7 @@
 
 package org.apache.geronimo.gshell.common;
 
+import java.lang.reflect.Array;
 import java.util.List;
 
 /**
@@ -32,13 +33,16 @@
         return shift(args, 1);
     }
 
-    public static Object[] shift(final Object[] args, int pos) {
-        assert args != null;
-        assert args.length >= pos;
+    public static Object[] shift(final Object[] source, int pos) {
+        assert source != null;
+        assert source.length >= pos;
 
-        Object[] _args = new Object[args.length - pos];
-        System.arraycopy(args, pos, _args, 0, _args.length);
-        return _args;
+        Object[] target = (Object[])
+            Array.newInstance(source.getClass().getComponentType(), source.length - pos);
+        
+        System.arraycopy(source, pos, target, 0, target.length);
+
+        return target;
     }
 
     public static String asString(final Object[] args) {

Modified: geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/test/java/org/apache/geronimo/gshell/common/ArgumentsTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/test/java/org/apache/geronimo/gshell/common/ArgumentsTest.java?rev=574416&r1=574415&r2=574416&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/test/java/org/apache/geronimo/gshell/common/ArgumentsTest.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-support/gshell-common/src/test/java/org/apache/geronimo/gshell/common/ArgumentsTest.java Mon Sep 10 17:49:15 2007
@@ -40,4 +40,20 @@
         assertEquals(3, shifted[1]);
         assertEquals(4, shifted[2]);
     }
+
+    public void testShift2() {
+        Object[] args = { "a", "b", 1, 2 };
+
+        Object[] shifted = Arguments.shift(args);
+
+        assertEquals(args.length - 1, shifted.length);
+    }
+
+    public void testShift3() {
+        String[] args = { "a" };
+
+        Object[] shifted = Arguments.shift(args);
+
+        assertEquals(args.length - 1, shifted.length);
+    }
 }

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

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



Mime
View raw message