geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r584161 - in /geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell: CommandLineBuilder.java DefaultCommandLineBuilder.java
Date Fri, 12 Oct 2007 13:28:36 GMT
Author: gnodet
Date: Fri Oct 12 06:27:54 2007
New Revision: 584161

URL: http://svn.apache.org/viewvc?rev=584161&view=rev
Log:
Refactor CommandLineBuilder to an interface

Added:
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultCommandLineBuilder.java
      - copied, changed from r583810, geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/CommandLineBuilder.java
Modified:
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/CommandLineBuilder.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=584161&r1=584160&r2=584161&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 Oct 12 06:27:54 2007
@@ -19,85 +19,14 @@
 
 package org.apache.geronimo.gshell;
 
-import java.io.Reader;
-import java.io.StringReader;
-
-import org.apache.geronimo.gshell.command.CommandExecutor;
-import org.apache.geronimo.gshell.parser.ASTCommandLine;
-import org.apache.geronimo.gshell.parser.CommandLineParser;
 import org.apache.geronimo.gshell.parser.ParseException;
-import org.apache.geronimo.gshell.shell.Environment;
-import org.codehaus.plexus.PlexusContainer;
-import org.codehaus.plexus.component.annotations.Component;
-import org.codehaus.plexus.component.annotations.Requirement;
-import org.codehaus.plexus.util.IOUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * Builds {@link CommandLine} instances ready for executing.
  *
  * @version $Rev$ $Date$
  */
-@Component(role=CommandLineBuilder.class)
-public class CommandLineBuilder
+public interface CommandLineBuilder
 {
-    private Logger log = LoggerFactory.getLogger(getClass());
-
-    @Requirement
-    private PlexusContainer container;
-
-    private CommandLineParser parser = new CommandLineParser();
-
-    public CommandLineBuilder() {}
-    
-    public CommandLineBuilder(final PlexusContainer container) {
-        this.container = container;
-    }
-
-    private ASTCommandLine parse(final String input) throws ParseException {
-        assert input != null;
-
-        Reader reader = new StringReader(input);
-        ASTCommandLine cl;
-        try {
-            cl = parser.parse(reader);
-        }
-        finally {
-            IOUtil.close(reader);
-        }
-
-        // If debug is enabled, the log the parse tree
-        if (log.isDebugEnabled()) {
-            LoggingVisitor logger = new LoggingVisitor(log);
-            cl.jjtAccept(logger, null);
-        }
-
-        return cl;
-    }
-
-    public CommandLine create(final String commandLine) throws ParseException {
-        assert commandLine != null;
-
-        if (commandLine.trim().length() == 0) {
-            throw new IllegalArgumentException("Command line is empty");
-        }
-
-        try {
-            CommandExecutor executor = (CommandExecutor) container.lookup(CommandExecutor.class);
-            Environment env = (Environment) container.lookup(Environment.class);
-
-            final ExecutingVisitor visitor = new ExecutingVisitor(executor, env);
-            final ASTCommandLine root = parse(commandLine);
-
-            return new CommandLine() {
-                public Object execute() throws Exception {
-                    return root.jjtAccept(visitor, null);
-                }
-            };
-        }
-        catch (Exception e) {
-            throw new ErrorNotification(e);
-        }
-    }
+    CommandLine create(final String commandLine) throws ParseException;
 }

Copied: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultCommandLineBuilder.java
(from r583810, 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/DefaultCommandLineBuilder.java?p2=geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/DefaultCommandLineBuilder.java&p1=geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/CommandLineBuilder.java&r1=583810&r2=584161&rev=584161&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/DefaultCommandLineBuilder.java
Fri Oct 12 06:27:54 2007
@@ -40,7 +40,7 @@
  * @version $Rev$ $Date$
  */
 @Component(role=CommandLineBuilder.class)
-public class CommandLineBuilder
+public class DefaultCommandLineBuilder implements CommandLineBuilder
 {
     private Logger log = LoggerFactory.getLogger(getClass());
 
@@ -49,9 +49,9 @@
 
     private CommandLineParser parser = new CommandLineParser();
 
-    public CommandLineBuilder() {}
+    public DefaultCommandLineBuilder() {}
     
-    public CommandLineBuilder(final PlexusContainer container) {
+    public DefaultCommandLineBuilder(final PlexusContainer container) {
         this.container = container;
     }
 



Mime
View raw message