geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r693716 [2/2] - in /geronimo/gshell/trunk: ./ gshell-api/src/main/java/org/apache/geronimo/gshell/command/ gshell-application/src/main/java/org/apache/geronimo/gshell/application/ gshell-assembly/src/main/underlay/etc/ gshell-cli/ gshell-cl...
Date Wed, 10 Sep 2008 07:33:39 GMT
Added: geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/shell/LoggingVisitor.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/shell/LoggingVisitor.java?rev=693716&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/shell/LoggingVisitor.java
(added)
+++ geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/shell/LoggingVisitor.java
Wed Sep 10 00:33:37 2008
@@ -0,0 +1,139 @@
+/*
+ * 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.wisdom.shell;
+
+import org.apache.geronimo.gshell.parser.ASTCommandLine;
+import org.apache.geronimo.gshell.parser.ASTExpression;
+import org.apache.geronimo.gshell.parser.ASTOpaqueString;
+import org.apache.geronimo.gshell.parser.ASTPlainString;
+import org.apache.geronimo.gshell.parser.ASTProcess;
+import org.apache.geronimo.gshell.parser.ASTQuotedString;
+import org.apache.geronimo.gshell.parser.CommandLineParserVisitor;
+import org.apache.geronimo.gshell.parser.SimpleNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Visitor whichs logs nodes in the tree.
+ *
+ * @version $Rev$ $Date$
+ */
+public class LoggingVisitor
+    implements CommandLineParserVisitor
+{
+    public static enum Level {
+        INFO,
+        DEBUG
+    }
+
+    private final Logger log;
+
+    private final Level level;
+
+    private int indent = 0;
+
+    public LoggingVisitor() {
+        this(LoggerFactory.getLogger(LoggingVisitor.class));
+    }
+
+    public LoggingVisitor(final Logger log) {
+        this(log, Level.DEBUG);
+    }
+
+    public LoggingVisitor(final Logger log, final Level level) {
+        assert log != null;
+        assert level != null;
+
+        this.log = log;
+        this.level = level;
+    }
+
+    private Object log(final Class type, final SimpleNode node, Object data) {
+        // Short-circuit of logging level does not match
+        switch (level) {
+            case INFO:
+                if (!log.isInfoEnabled()) {
+                    return data;
+                }
+                break;
+
+            case DEBUG:
+                if (!log.isDebugEnabled()) {
+                    return data;
+                }
+                break;
+        }
+
+        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);
+        }
+
+        switch (level) {
+            case INFO:
+                log.info(buff.toString());
+                break;
+
+            case DEBUG:
+                log.debug(buff.toString());
+                break;
+        }
+
+        indent++;
+        data = node.childrenAccept(this, data);
+        indent--;
+
+        return data;
+    }
+
+    public Object visit(final SimpleNode node, Object data) {
+        return log(SimpleNode.class, node, data);
+    }
+
+    public Object visit(final ASTCommandLine node, Object data) {
+        return log(ASTCommandLine.class, node, data);
+    }
+
+    public Object visit(final ASTExpression node, Object data) {
+        return log(ASTExpression.class, node, data);
+    }
+
+    public Object visit(ASTProcess node, Object data) {
+        return log(ASTProcess.class, node, data);
+    }
+
+    public Object visit(final ASTQuotedString node, Object data) {
+        return log(ASTQuotedString.class, node, data);
+    }
+
+    public Object visit(final ASTOpaqueString node, Object data) {
+        return log(ASTOpaqueString.class, node, data);
+    }
+
+    public Object visit(final ASTPlainString node, Object data) {
+        return log(ASTPlainString.class, node, data);
+    }
+}
\ No newline at end of file

Propchange: geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/shell/LoggingVisitor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/shell/LoggingVisitor.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/shell/LoggingVisitor.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/shell/LoggingVisitor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java?rev=693716&r1=693715&r2=693716&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java
(original)
+++ geronimo/gshell/trunk/gshell-wisdom/src/main/java/org/apache/geronimo/gshell/wisdom/shell/ShellImpl.java
Wed Sep 10 00:33:37 2008
@@ -22,6 +22,7 @@
 import jline.History;
 import org.apache.geronimo.gshell.ansi.Renderer;
 import org.apache.geronimo.gshell.application.ApplicationManager;
+import org.apache.geronimo.gshell.application.ApplicationContext;
 import org.apache.geronimo.gshell.command.Variables;
 import org.apache.geronimo.gshell.commandline.CommandLineExecutor;
 import org.apache.geronimo.gshell.console.Console;
@@ -39,7 +40,7 @@
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 
-import javax.annotation.Resource;
+import javax.annotation.PostConstruct;
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileReader;
@@ -91,8 +92,8 @@
         return true;
     }
 
-    /*
-    public void initialize() throws InitializationException {
+    @PostConstruct
+    public void init() {
         assert applicationManager != null;
 
         // Dereference some bits from the applciation context
@@ -105,10 +106,9 @@
             loadProfileScripts();
         }
         catch (Exception e) {
-            throw new InitializationException(e.getMessage(), e);
+            throw new RuntimeException(e.getMessage(), e);
         }
     }
-    */
 
     //
     // Command Execution (all delegates)

Modified: geronimo/gshell/trunk/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/pom.xml?rev=693716&r1=693715&r2=693716&view=diff
==============================================================================
--- geronimo/gshell/trunk/pom.xml (original)
+++ geronimo/gshell/trunk/pom.xml Wed Sep 10 00:33:37 2008
@@ -294,6 +294,111 @@
                 <artifactId>bsh</artifactId>
                 <version>2.0b4</version>
             </dependency>
+
+            <dependency>
+                <groupId>org.springframework</groupId>
+                <artifactId>spring-core</artifactId>
+                <version>2.5.5</version>
+                <exclusions>
+                    <exclusion>
+                        <groupId>commons-logging</groupId>
+                        <artifactId>commons-logging</artifactId>
+                    </exclusion>
+                </exclusions>
+            </dependency>
+
+            <dependency>
+                <groupId>org.springframework</groupId>
+                <artifactId>spring-context</artifactId>
+                <version>2.5.5</version>
+                <exclusions>
+                    <exclusion>
+                        <groupId>commons-logging</groupId>
+                        <artifactId>commons-logging</artifactId>
+                    </exclusion>
+                </exclusions>
+            </dependency>
+
+            <dependency>
+                <groupId>org.springframework</groupId>
+                <artifactId>spring-beans</artifactId>
+                <version>2.5.5</version>
+                <exclusions>
+                    <exclusion>
+                        <groupId>commons-logging</groupId>
+                        <artifactId>commons-logging</artifactId>
+                    </exclusion>
+                </exclusions>
+            </dependency>
+
+            <dependency>
+                <groupId>org.springframework</groupId>
+                <artifactId>spring-aop</artifactId>
+                <version>2.5.5</version>
+                <exclusions>
+                    <exclusion>
+                        <groupId>commons-logging</groupId>
+                        <artifactId>commons-logging</artifactId>
+                    </exclusion>
+                </exclusions>
+            </dependency>
+
+            <dependency>
+                <groupId>org.springframework</groupId>
+                <artifactId>spring-test</artifactId>
+                <version>2.5.5</version>
+                <exclusions>
+                    <exclusion>
+                        <groupId>commons-logging</groupId>
+                        <artifactId>commons-logging</artifactId>
+                    </exclusion>
+                </exclusions>
+            </dependency>
+            
+            <!--
+            <dependency>
+                <groupId>org.springframework.osgi</groupId>
+                <artifactId>spring-osgi-core</artifactId>
+                <version>1.1.0</version>
+            </dependency>
+
+            <dependency>
+                <groupId>org.springframework.osgi</groupId>
+                <artifactId>spring-osgi-extender</artifactId>
+                <version>1.1.0</version>
+            </dependency>
+
+            <dependency>
+                <groupId>org.springframework.osgi</groupId>
+                <artifactId>spring-osgi-io</artifactId>
+                <version>1.1.0</version>
+            </dependency>
+
+            <dependency>
+                <groupId>org.springframework.osgi</groupId>
+                <artifactId>spring-osgi-annotation</artifactId>
+                <version>1.1.0</version>
+            </dependency>
+
+            <dependency>
+                <groupId>org.springframework.osgi</groupId>
+                <artifactId>spring-osgi-test</artifactId>
+                <version>1.1.0</version>
+                <scope>test</scope>
+            </dependency>
+            -->
+            
+            <dependency>
+                <groupId>org.jmock</groupId>
+                <artifactId>jmock-junit3</artifactId>
+                <version>2.5.1</version>
+            </dependency>
+            
+            <dependency>
+                <groupId>org.easymock</groupId>
+                <artifactId>easymock</artifactId>
+                <version>2.4</version>
+            </dependency>
             
             <!-- INTERNAL -->
             
@@ -333,11 +438,19 @@
                 <version>1.0-alpha-2-SNAPSHOT</version>
             </dependency>
 
+            <!--
             <dependency>
                 <groupId>org.apache.geronimo.gshell.support</groupId>
                 <artifactId>gshell-plexus</artifactId>
                 <version>1.0-alpha-2-SNAPSHOT</version>
             </dependency>
+            -->
+
+            <dependency>
+                <groupId>org.apache.geronimo.gshell.support</groupId>
+                <artifactId>gshell-spring</artifactId>
+                <version>1.0-alpha-2-SNAPSHOT</version>
+            </dependency>
 
             <dependency>
                 <groupId>org.apache.geronimo.gshell.support</groupId>
@@ -496,7 +609,9 @@
         <module>gshell-application</module>
         <module>gshell-parser</module>
         <module>gshell-layout</module>
+        <!--
         <module>gshell-rapture</module>
+        -->
         <module>gshell-wisdom</module>
         <module>gshell-cli</module>
         <module>gshell-commands</module>



Mime
View raw message