geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r573669 - in /geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell: CommandLineBuilder.java ExecutingVisitor.java ShellImpl.java console/Console.java
Date Fri, 07 Sep 2007 18:47:20 GMT
Author: jdillon
Date: Fri Sep  7 11:47:20 2007
New Revision: 573669

URL: http://svn.apache.org/viewvc?rev=573669&view=rev
Log:
Don't use injection for some of this parsing muck, we can simply wire them up internally

Modified:
    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/ExecutingVisitor.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ShellImpl.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/Console.java

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=573669&r1=573668&r2=573669&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
Fri Sep  7 11:47:20 2007
@@ -26,6 +26,7 @@
 import org.apache.geronimo.gshell.parser.CommandLineParser;
 import org.apache.geronimo.gshell.parser.ParseException;
 import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.evaluator.ExpressionEvaluator;
 import org.codehaus.plexus.component.annotations.Component;
 import org.codehaus.plexus.component.annotations.Requirement;
 import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
@@ -37,17 +38,25 @@
  *
  * @version $Rev$ $Date$
  */
-@Component(role=CommandLineBuilder.class)
 public class CommandLineBuilder
 {
     private Logger log = LoggerFactory.getLogger(getClass());
 
-    @Requirement
-    private PlexusContainer container;
-
-    @Requirement
     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();
+    }
+
     private ASTCommandLine parse(final String input) throws ParseException {
         assert input != null;
 
@@ -70,18 +79,7 @@
             throw new IllegalArgumentException("Command line is empty");
         }
 
-        //
-        // HACK: Look up the vistor... just make it work for now
-        //
-        
-        final ExecutingVisitor visitor;
-        try {
-            visitor = (ExecutingVisitor) container.lookup(ExecutingVisitor.class);
-        }
-        catch (ComponentLookupException e) {
-            throw new RuntimeException(e);
-        }
-
+        final ExecutingVisitor visitor = new ExecutingVisitor(shell, evaluator);
         final ASTCommandLine root = parse(commandLine);
         
         return new CommandLine() {

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=573669&r1=573668&r2=573669&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
Fri Sep  7 11:47:20 2007
@@ -44,18 +44,23 @@
  *
  * @version $Rev$ $Date$
  */
-@Component(role=ExecutingVisitor.class)
 public class ExecutingVisitor
     implements CommandLineParserVisitor
 {
-    private static final Logger log = LoggerFactory.getLogger(ExecutingVisitor.class);
+    private final Logger log = LoggerFactory.getLogger(getClass());
 
-    @Requirement
     private Shell shell;
 
-    @Requirement
     private ExpressionEvaluator evaluator;
 
+    public ExecutingVisitor(final Shell shell, final ExpressionEvaluator evaluator) {
+        assert shell != null;
+        assert evaluator != null;
+
+        this.shell = shell;
+        this.evaluator = evaluator;
+    }
+
     public Object visit(final SimpleNode node, final Object data) {
         assert node != null;
 
@@ -105,7 +110,7 @@
         assert data != null;
         assert data instanceof List;
 
-        List<Object> args = (List<Object>)data;
+        List args = (List)data;
         args.add(value);
 
         return value;

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ShellImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ShellImpl.java?rev=573669&r1=573668&r2=573669&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ShellImpl.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ShellImpl.java
Fri Sep  7 11:47:20 2007
@@ -30,6 +30,9 @@
 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;
 
@@ -40,7 +43,7 @@
  */
 @Component(role=Shell.class)
 public class ShellImpl
-    implements Shell
+    implements Shell, Initializable
 {
     private Logger log = LoggerFactory.getLogger(getClass());
 
@@ -54,20 +57,15 @@
     private LayoutManager layoutManager;
 
     @Requirement
-    private CommandLineBuilder commandLineBuilder;
-
-    private final Variables variables = new VariablesImpl();
+    private ExpressionEvaluator evaluator;
 
-    public ShellImpl() {
-        // empty
-    }
+    private CommandLineBuilder commandLineBuilder;
 
-    //
-    // HACK: This is for testing, need to weed out and refactor all this shiz
-    //
+    private Variables variables = new VariablesImpl();
 
-    public ShellImpl(final IO io) {
-        this.io = io;
+    public void initialize() throws InitializationException {
+        assert evaluator != null;
+        commandLineBuilder = new CommandLineBuilder(this, evaluator);
     }
 
     public Variables getVariables() {
@@ -81,9 +79,7 @@
     public Object execute(final String commandLine) throws Exception {
         assert commandLine != null;
 
-        if (log.isInfoEnabled()) {
-            log.info("Executing (String): " + commandLine);
-        }
+        log.info("Executing (String): {}", commandLine);
 
         CommandLine cl = commandLineBuilder.create(commandLine);
         return cl.execute();

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/Console.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/Console.java?rev=573669&r1=573668&r2=573669&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/Console.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/Console.java
Fri Sep  7 11:47:20 2007
@@ -128,7 +128,8 @@
                 running = work();
             }
             catch (Throwable t) {
-                log.debug("Work failed: {}", t);
+                // Don't use {} here so we get the throwable detail in the log stream
+                log.debug("Work failed: " + t, t);
                 
                 if (errorHandler != null) {
                     ErrorHandler.Result result = errorHandler.handleError(t);



Mime
View raw message