You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2006/05/30 04:25:59 UTC
svn commit: r410172 - in /geronimo/sandbox/gshell/trunk: gshell-assembly/
gshell-assembly/src/main/assembly/ gshell-assembly/src/main/config/
gshell-cli/src/main/resources/META-INF/org.apache.geronimo.gshell/
gshell-cli/src/main/resources/META-INF/spri...
Author: jdillon
Date: Mon May 29 19:25:59 2006
New Revision: 410172
URL: http://svn.apache.org/viewvc?rev=410172&view=rev
Log:
Drop the bulk of the Spring configuration bits
Added a visitor to log the tree when --debug is enabled
Dropped CommandLine prefix to ExecutingVisitor class, felt like too much
Added:
geronimo/sandbox/gshell/trunk/gshell-assembly/NOTICE.txt (with props)
geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/ExecutingVisitor.java (contents, props changed)
- copied, changed from r410154, geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/CommandLineExecutingVisitor.java
geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/LoggingVisitor.java (with props)
geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/commandline/ExecutingVisitorTest.java (contents, props changed)
- copied, changed from r410154, geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/commandline/CommandLineExecutingVisitorTest.java
Removed:
geronimo/sandbox/gshell/trunk/gshell-cli/src/main/resources/META-INF/org.apache.geronimo.gshell/
geronimo/sandbox/gshell/trunk/gshell-cli/src/main/resources/META-INF/spring/
geronimo/sandbox/gshell/trunk/gshell-commands/scripting-commands/src/main/resources/META-INF/org.apache.geronimo.gshell/
geronimo/sandbox/gshell/trunk/gshell-commands/standard-commands/src/main/resources/META-INF/org.apache.geronimo.gshell/
geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/CommandLineExecutingVisitor.java
geronimo/sandbox/gshell/trunk/gshell-core/src/main/resources/META-INF/org.apache.geronimo.gshell/
geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/commandline/CommandLineExecutingVisitorTest.java
Modified:
geronimo/sandbox/gshell/trunk/gshell-assembly/src/main/assembly/bin.xml
geronimo/sandbox/gshell/trunk/gshell-assembly/src/main/config/gshell.conf (props changed)
geronimo/sandbox/gshell/trunk/gshell-assembly/src/main/config/gshell.xml
geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/GShell.java
geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/CommandLine.java
geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/CommandLineBuilder.java
Added: geronimo/sandbox/gshell/trunk/gshell-assembly/NOTICE.txt
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-assembly/NOTICE.txt?rev=410172&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-assembly/NOTICE.txt (added)
+++ geronimo/sandbox/gshell/trunk/gshell-assembly/NOTICE.txt Mon May 29 19:25:59 2006
@@ -0,0 +1,2 @@
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
Propchange: geronimo/sandbox/gshell/trunk/gshell-assembly/NOTICE.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-assembly/NOTICE.txt
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-assembly/NOTICE.txt
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/sandbox/gshell/trunk/gshell-assembly/src/main/assembly/bin.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-assembly/src/main/assembly/bin.xml?rev=410172&r1=410171&r2=410172&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-assembly/src/main/assembly/bin.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-assembly/src/main/assembly/bin.xml Mon May 29 19:25:59 2006
@@ -14,6 +14,7 @@
<fileSet>
<includes>
<include>README.txt</include>
+ <include>NOTICE.txt</include>
<include>LICENSE.txt</include>
</includes>
</fileSet>
Propchange: geronimo/sandbox/gshell/trunk/gshell-assembly/src/main/config/gshell.conf
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-assembly/src/main/config/gshell.conf
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-assembly/src/main/config/gshell.conf
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/sandbox/gshell/trunk/gshell-assembly/src/main/config/gshell.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-assembly/src/main/config/gshell.xml?rev=410172&r1=410171&r2=410172&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-assembly/src/main/config/gshell.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-assembly/src/main/config/gshell.xml Mon May 29 19:25:59 2006
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
-<!-- $Id -->
+<!-- $Id$ -->
<beans>
Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/GShell.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/GShell.java?rev=410172&r1=410171&r2=410172&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/GShell.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/GShell.java Mon May 29 19:25:59 2006
@@ -42,7 +42,6 @@
this.ctx = new ClassPathXmlApplicationContext(new String[] {
"classpath*:/gshell.xml",
- "classpath*:/META-INF/org.apache.geronimo.gshell/components.xml",
});
this.impl = (GShellImpl)ctx.getBean("gshell");
Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/CommandLine.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/CommandLine.java?rev=410172&r1=410171&r2=410172&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/CommandLine.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/CommandLine.java Mon May 29 19:25:59 2006
@@ -17,7 +17,7 @@
package org.apache.geronimo.gshell.commandline;
/**
- * ???
+ * A generic abstraction of an executable command-line.
*
* @version $Id$
*/
Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/CommandLineBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/CommandLineBuilder.java?rev=410172&r1=410171&r2=410172&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/CommandLineBuilder.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/CommandLineBuilder.java Mon May 29 19:25:59 2006
@@ -27,7 +27,7 @@
import java.io.StringReader;
/**
- * ???
+ * Builds {@link CommandLine} instances ready for executing.
*
* @version $Id$
*/
@@ -55,11 +55,11 @@
CommandLineParser parser = new CommandLineParser();
ASTCommandLine cl = parser.parse(reader);
- //
- // TODO: Log results with log visitor
- //
-
- cl.dump("# ");
+ // If debug is enabled, the log the parse tree
+ if (log.isDebugEnabled()) {
+ LoggingVisitor logger = new LoggingVisitor(log);
+ cl.jjtAccept(logger, null);
+ }
return cl;
}
@@ -73,7 +73,7 @@
}
final ASTCommandLine root = parse(commandLine);
- final CommandLineExecutingVisitor visitor = new CommandLineExecutingVisitor(this.executor);
+ final ExecutingVisitor visitor = new ExecutingVisitor(this.executor);
return new CommandLine() {
public void execute() throws Exception {
Copied: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/ExecutingVisitor.java (from r410154, geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/CommandLineExecutingVisitor.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/ExecutingVisitor.java?p2=geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/ExecutingVisitor.java&p1=geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/CommandLineExecutingVisitor.java&r1=410154&r2=410172&rev=410172&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/CommandLineExecutingVisitor.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/ExecutingVisitor.java Mon May 29 19:25:59 2006
@@ -34,18 +34,18 @@
import java.util.ArrayList;
/**
- * Command line parser visitor which will execute command-lines as parsed.
+ * Visitor which will execute command-lines as parsed.
*
* @version $Id$
*/
-public class CommandLineExecutingVisitor
+public class ExecutingVisitor
implements CommandLineParserVisitor
{
- private static final Log log = LogFactory.getLog(CommandLineExecutingVisitor.class);
+ private static final Log log = LogFactory.getLog(ExecutingVisitor.class);
private CommandExecutor executor;
- public CommandLineExecutingVisitor(final CommandExecutor executor) {
+ public ExecutingVisitor(final CommandExecutor executor) {
if (executor == null) {
throw new IllegalArgumentException("Executor is null");
}
Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/ExecutingVisitor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/ExecutingVisitor.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/ExecutingVisitor.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/LoggingVisitor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/LoggingVisitor.java?rev=410172&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/LoggingVisitor.java (added)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/LoggingVisitor.java Mon May 29 19:25:59 2006
@@ -0,0 +1,137 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed 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.commandline;
+
+import org.apache.geronimo.gshell.commandline.parser.CommandLineParserVisitor;
+import org.apache.geronimo.gshell.commandline.parser.SimpleNode;
+import org.apache.geronimo.gshell.commandline.parser.ASTCommandLine;
+import org.apache.geronimo.gshell.commandline.parser.ASTExpression;
+import org.apache.geronimo.gshell.commandline.parser.ASTQuotedString;
+import org.apache.geronimo.gshell.commandline.parser.ASTOpaqueString;
+import org.apache.geronimo.gshell.commandline.parser.ASTPlainString;
+import org.apache.geronimo.gshell.commandline.parser.Node;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Visitor whichs logs nodes in the tree.
+ *
+ * @version $Id$
+ */
+public class LoggingVisitor
+ implements CommandLineParserVisitor
+{
+ private final Log log;
+
+ private int indent = 0;
+
+ public LoggingVisitor() {
+ this(LogFactory.getLog(LoggingVisitor.class));
+ }
+
+ public LoggingVisitor(final Log log) {
+ if (log == null) {
+ throw new IllegalArgumentException("Log is null");
+ }
+
+ this.log = log;
+ }
+
+ private void log(final Class type, final Node node, final Object data) {
+ if (!log.isDebugEnabled()) {
+ return;
+ }
+
+ StringBuffer buff = new StringBuffer();
+
+ for (int i=0; i<indent; i++) {
+ buff.append(" ");
+ }
+
+ buff.append(node).append(" (").append(type.getName()).append(")");
+ if (data != null) {
+ buff.append("; Data: ").append(data);
+ }
+
+ //
+ // TODO: May wany to expose DEBUG/INFO switch
+ //
+
+ log.debug(buff);
+ }
+
+ public Object visit(final SimpleNode node, Object data) {
+ log(SimpleNode.class, node, data);
+
+ indent++;
+ data = node.childrenAccept(this, data);
+ indent--;
+
+ return data;
+ }
+
+ public Object visit(final ASTCommandLine node, Object data) {
+ log(ASTCommandLine.class, node, data);
+
+ indent++;
+ data = node.childrenAccept(this, data);
+ indent--;
+
+ return data;
+ }
+
+ public Object visit(final ASTExpression node, Object data) {
+ log(ASTExpression.class, node, data);
+
+ indent++;
+ data = node.childrenAccept(this, data);
+ indent--;
+
+ return data;
+ }
+
+ public Object visit(final ASTQuotedString node, Object data) {
+ log(ASTQuotedString.class, node, data);
+
+ indent++;
+ data = node.childrenAccept(this, data);
+ indent--;
+
+ return data;
+ }
+
+ public Object visit(final ASTOpaqueString node, Object data) {
+ log(ASTOpaqueString.class, node, data);
+
+ indent++;
+ data = node.childrenAccept(this, data);
+ indent--;
+
+ return data;
+ }
+
+ public Object visit(final ASTPlainString node, Object data) {
+ log(ASTPlainString.class, node, data);
+
+ indent++;
+ data = node.childrenAccept(this, data);
+ indent--;
+
+ return data;
+ }
+}
Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/LoggingVisitor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/LoggingVisitor.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/LoggingVisitor.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Copied: geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/commandline/ExecutingVisitorTest.java (from r410154, geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/commandline/CommandLineExecutingVisitorTest.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/commandline/ExecutingVisitorTest.java?p2=geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/commandline/ExecutingVisitorTest.java&p1=geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/commandline/CommandLineExecutingVisitorTest.java&r1=410154&r2=410172&rev=410172&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/commandline/CommandLineExecutingVisitorTest.java (original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/commandline/ExecutingVisitorTest.java Mon May 29 19:25:59 2006
@@ -18,44 +18,19 @@
import junit.framework.TestCase;
-import java.io.Reader;
-import java.io.StringReader;
-
-import org.apache.geronimo.gshell.commandline.parser.ASTCommandLine;
-import org.apache.geronimo.gshell.commandline.parser.ParseException;
-import org.apache.geronimo.gshell.commandline.parser.CommandLineParser;
-import org.apache.geronimo.gshell.command.CommandExecutor;
import org.apache.geronimo.gshell.command.MockCommandExecutor;
/**
- * Unit tests for the {@link CommandLineExecutingVisitor} usage.
+ * Unit tests for the {@link ExecutingVisitor} usage.
*
* @version $Id$
*/
-public class CommandLineExecutingVisitorTest
+public class ExecutingVisitorTest
extends TestCase
{
- private ASTCommandLine parse(final String input) throws ParseException {
- assert input != null;
-
- Reader reader = new StringReader(input);
- CommandLineParser parser = new CommandLineParser();
- ASTCommandLine cl = parser.parse(reader);
-
- //
- // TODO: Remove eventually, may want to make nodes use logging to dump too
- //
-
- cl.dump("> ");
-
- assertNotNull(cl);
-
- return cl;
- }
-
public void testConstructor() throws Exception {
try {
- new CommandLineExecutingVisitor(null);
+ new ExecutingVisitor(null);
fail("Accepted null value");
}
catch (IllegalArgumentException expected) {
@@ -63,6 +38,6 @@
}
// Happy day
- new CommandLineExecutingVisitor(new MockCommandExecutor());
+ new ExecutingVisitor(new MockCommandExecutor());
}
}
Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/commandline/ExecutingVisitorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/commandline/ExecutingVisitorTest.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/sandbox/gshell/trunk/gshell-core/src/test/java/org/apache/geronimo/gshell/commandline/ExecutingVisitorTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain