geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r410800 - in /geronimo/sandbox/gshell/trunk: gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/ gshell-commands/standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/ gshell-core/src/main/java/org/apache/geronim...
Date Thu, 01 Jun 2006 08:52:22 GMT
Author: jdillon
Date: Thu Jun  1 01:52:20 2006
New Revision: 410800

URL: http://svn.apache.org/viewvc?rev=410800&view=rev
Log:
Re-implemented telnet server bits with NVT4J, since it seems to handle the unbuffered bits
betterish (still a tad off)
Fixed command support to allow ExitNotification to propagate
Simplify IO/Console bits a tad
Support for richer JLine integration

Added:
    geronimo/sandbox/gshell/trunk/gshell-server/repository/
    geronimo/sandbox/gshell/trunk/gshell-server/repository/nvt4j/
    geronimo/sandbox/gshell/trunk/gshell-server/repository/nvt4j/nvt4j/
    geronimo/sandbox/gshell/trunk/gshell-server/repository/nvt4j/nvt4j/1.0a1/
    geronimo/sandbox/gshell/trunk/gshell-server/repository/nvt4j/nvt4j/1.0a1/nvt4j-1.0a1.jar
  (with props)
    geronimo/sandbox/gshell/trunk/gshell-server/repository/nvt4j/nvt4j/maven-metadata-local.xml
  (with props)
    geronimo/sandbox/gshell/trunk/gshell-server/src/main/java/org/apache/geronimo/gshell/server/telnet/
    geronimo/sandbox/gshell/trunk/gshell-server/src/main/java/org/apache/geronimo/gshell/server/telnet/TelnetTerminal.java
  (with props)
Modified:
    geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
    geronimo/sandbox/gshell/trunk/gshell-commands/standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/CatCommand.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ExitNotification.java
    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/InteractiveGShell.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandManager.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/LoggingVisitor.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/IO.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/InteractiveConsole.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/JLineConsole.java
    geronimo/sandbox/gshell/trunk/gshell-retro-assembly/pom.xml   (contents, props changed)
    geronimo/sandbox/gshell/trunk/gshell-retro-assembly/src/main/assembly/bin.xml   (contents,
props changed)
    geronimo/sandbox/gshell/trunk/gshell-server/pom.xml
    geronimo/sandbox/gshell/trunk/gshell-server/src/main/java/org/apache/geronimo/gshell/server/GShellServer.java
    geronimo/sandbox/gshell/trunk/gshell-server/src/main/java/org/apache/geronimo/gshell/server/ServerCommand.java
    geronimo/sandbox/gshell/trunk/gshell-server/src/main/java/org/apache/geronimo/gshell/server/SocketServerDaemon.java

Modified: geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java?rev=410800&r1=410799&r2=410800&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-cli/src/main/java/org/apache/geronimo/gshell/cli/Main.java
Thu Jun  1 01:52:20 2006
@@ -31,6 +31,8 @@
 import org.apache.geronimo.gshell.GShell;
 import org.apache.geronimo.gshell.InteractiveGShell;
 import org.apache.geronimo.gshell.console.IO;
+import org.apache.geronimo.gshell.console.Console;
+import org.apache.geronimo.gshell.console.JLineConsole;
 
 import org.apache.geronimo.gshell.util.Version;
 import org.apache.geronimo.gshell.util.Banner;
@@ -164,8 +166,8 @@
         if (line.hasOption('D')) {
             String[] values = line.getOptionValues('D');
 
-            for (int i=0; i<values.length; i++) {
-                setPropertyFrom(values[i]);
+            for (String value : values) {
+                setPropertyFrom(value);
             }
         }
 
@@ -225,7 +227,16 @@
         int status = 0;
 
         if (interactive) {
-            InteractiveGShell interp = new InteractiveGShell(io, gshell);
+            //
+            // HACK: This is JLine specific... refactor
+            //
+
+            //
+            // TODO: Explicitly pass in the terminal
+            //
+
+            Console console = new JLineConsole(io);
+            InteractiveGShell interp = new InteractiveGShell(console, gshell);
 
             // Check if there are args, and run them and then enter interactive
             if (args.length != 0) {

Modified: geronimo/sandbox/gshell/trunk/gshell-commands/standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/CatCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-commands/standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/CatCommand.java?rev=410800&r1=410799&r2=410800&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-commands/standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/CatCommand.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-commands/standard-commands/src/main/java/org/apache/geronimo/gshell/commands/standard/CatCommand.java
Thu Jun  1 01:52:20 2006
@@ -102,10 +102,10 @@
         assert files != null;
         
         IO io = getIO();
-        
-        for (int i=0; i<files.length; i++) {
+
+        for (String filename : files) {
             BufferedReader reader;
-            
+
             //
             // Support "-" if length is one, and read from io.in
             // This will help test command pipelines.
@@ -113,16 +113,15 @@
             if (files.length == 1 && "-".equals(files[0])) {
                 log.info("Printing STDIN");
                 reader = new BufferedReader(io.in);
-            }
-            else {
-                File file = new File(files[i]);
+            } else {
+                File file = new File(filename);
                 log.info("Printing file: " + file);
                 reader = new BufferedReader(new FileReader(file));
             }
-            
+
             String line;
             int lineno = 1;
-            
+
             while ((line = reader.readLine()) != null) {
                 if (displayLineNumbers) {
                     String gutter = StringUtils.leftPad(String.valueOf(lineno++), 6);
@@ -131,7 +130,7 @@
                 }
                 io.out.println(line);
             }
-            
+
             reader.close();
         }
     }

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ExitNotification.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ExitNotification.java?rev=410800&r1=410799&r2=410800&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ExitNotification.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/ExitNotification.java
Thu Jun  1 01:52:20 2006
@@ -16,12 +16,6 @@
 
 package org.apache.geronimo.gshell;
 
-import org.apache.geronimo.gshell.console.InteractiveConsole;
-import org.apache.geronimo.gshell.console.JLineConsole;
-import org.apache.geronimo.gshell.console.IO;
-
-import java.io.IOException;
-
 /**
  * Thrown to indicate that the current shell should exit.
  *

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=410800&r1=410799&r2=410800&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
Thu Jun  1 01:52:20 2006
@@ -51,7 +51,7 @@
         }
 
         this.io = io;
-        
+
         //
         // HACK: DI CommandManager...  Maybe need to setup the top-level container here
         //

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/InteractiveGShell.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/InteractiveGShell.java?rev=410800&r1=410799&r2=410800&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/InteractiveGShell.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/InteractiveGShell.java
Thu Jun  1 01:52:20 2006
@@ -17,8 +17,7 @@
 package org.apache.geronimo.gshell;
 
 import org.apache.geronimo.gshell.console.InteractiveConsole;
-import org.apache.geronimo.gshell.console.JLineConsole;
-import org.apache.geronimo.gshell.console.IO;
+import org.apache.geronimo.gshell.console.Console;
 
 import java.io.IOException;
 
@@ -30,9 +29,8 @@
 public class InteractiveGShell
     extends InteractiveConsole
 {
-    public InteractiveGShell(final IO io, final GShell gshell) throws IOException {
-        super(new JLineConsole(io),
-
+    public InteractiveGShell(final Console console, final GShell gshell) throws IOException
{
+        super(console,
             new InteractiveConsole.Executor() {
                 public Result execute(final String line) throws Exception {
                     assert line != null;
@@ -50,7 +48,6 @@
                     return Result.CONTINUE;
                 }
             },
-                
             new InteractiveConsole.Prompter() {
                 public String getPrompt() {
                     //

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandManager.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandManager.java?rev=410800&r1=410799&r2=410800&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandManager.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandManager.java
Thu Jun  1 01:52:20 2006
@@ -72,13 +72,16 @@
         }
     }
 
-    public CommandDefinition getCommandDefinition(final String name) throws CommandNotFoundException
{
+    public CommandDefinition getCommandDefinition(String name) throws CommandNotFoundException
{
         if (name == null) {
             throw new IllegalArgumentException("Name is null");
         }
         if (name.trim().length() == 0) {
             throw new IllegalArgumentException("Name is empty");
         }
+
+        // Make sure there is not funky whitespace in there (from Telnet or something)
+        name = name.trim();
 
         CommandDefinition def = commandDefMap.get(name);
         if (def == null) {

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java?rev=410800&r1=410799&r2=410800&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/command/CommandSupport.java
Thu Jun  1 01:52:20 2006
@@ -20,6 +20,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.gshell.console.IO;
 import org.apache.geronimo.gshell.util.Arguments;
+import org.apache.geronimo.gshell.ExitNotification;
 
 /**
  * Provides support for {@link Command} implemenations.
@@ -153,6 +154,13 @@
             }
 
             status = Command.FAILURE;
+        }
+        catch (ExitNotification n) {
+            //
+            // HACK: Propagate the notifciation
+            //
+
+            throw n;
         }
         catch (Error e) {
             log.error(e.getMessage());

Modified: 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=410800&r1=410799&r2=410800&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/LoggingVisitor.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/commandline/LoggingVisitor.java
Thu Jun  1 01:52:20 2006
@@ -26,7 +26,6 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.commons.lang.StringUtils;
 
 /**
  * Visitor whichs logs nodes in the tree.
@@ -84,7 +83,7 @@
         }
 
         StringBuffer buff = new StringBuffer();
-        
+
         for (int i=0; i<indent; i++) {
             buff.append(" ");
         }

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/IO.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/IO.java?rev=410800&r1=410799&r2=410800&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/IO.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/IO.java
Thu Jun  1 01:52:20 2006
@@ -18,10 +18,10 @@
 
 import java.io.InputStream;
 import java.io.InputStreamReader;
-import java.io.PrintStream;
 import java.io.PrintWriter;
 import java.io.Reader;
 import java.io.IOException;
+import java.io.OutputStream;
 
 /**
  * Container for input/output handles.
@@ -42,14 +42,14 @@
      *
      * @see #out
      */
-    public final PrintStream outputStream;
+    public final OutputStream outputStream;
 
     /**
      * Raw error output stream.
      *
      * @see #err
      */
-    public final PrintStream errorStream;
+    public final OutputStream errorStream;
 
     /**
      * Prefered input reader.
@@ -73,7 +73,7 @@
      * @param out   The output stream; must not be null
      * @param err   The error output stream; must not be null
      */
-    public IO(final InputStream in, final PrintStream out, final PrintStream err) {
+    public IO(final InputStream in, final OutputStream out, final OutputStream err) {
         if (in == null) {
             throw new IllegalArgumentException("Input stream is null");
         }
@@ -99,7 +99,7 @@
      * @param in    The input steam; must not be null
      * @param out   The output stream and error stream; must not be null
      */
-    public IO(final InputStream in, final PrintStream out) {
+    public IO(final InputStream in, final OutputStream out) {
         this(in, out, out);
     }
 

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/InteractiveConsole.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/InteractiveConsole.java?rev=410800&r1=410799&r2=410800&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/InteractiveConsole.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/InteractiveConsole.java
Thu Jun  1 01:52:20 2006
@@ -164,6 +164,11 @@
      */
     public static interface Prompter
     {
+        /**
+         * Return the prompt to be displayed.
+         *
+         * @return  The prompt to be displayed; must not be null
+         */
         String getPrompt();
     }
 }

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=410800&r1=410799&r2=410800&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
Thu Jun  1 01:52:20 2006
@@ -36,11 +36,23 @@
 
     private final ConsoleReader reader;
 
-    public JLineConsole(final IO io) throws IOException {
+    public JLineConsole(final IO io, final ConsoleReader reader) throws IOException {
         if (io == null) {
             throw new IllegalArgumentException("IO is null");
         }
+        if (reader == null) {
+            throw new IllegalArgumentException("Reader is null");
+        }
 
+        this.io = io;
+        this.reader = reader;
+    }
+
+    public JLineConsole(final IO io) throws IOException {
+        if (io == null) {
+            throw new IllegalArgumentException("IO is null");
+        }
+        
         this.io = io;
         this.reader = new ConsoleReader(io.inputStream, io.out);
     }

Modified: geronimo/sandbox/gshell/trunk/gshell-retro-assembly/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-retro-assembly/pom.xml?rev=410800&r1=410799&r2=410800&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-retro-assembly/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-retro-assembly/pom.xml Thu Jun  1 01:52:20 2006
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
-<!-- $Id: pom.xml 410438 2006-05-31 05:44:49Z jdillon $ -->
+<!-- $Id$ -->
 
 <project
     xmlns="http://maven.apache.org/POM/4.0.0"

Propchange: geronimo/sandbox/gshell/trunk/gshell-retro-assembly/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-retro-assembly/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-retro-assembly/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: geronimo/sandbox/gshell/trunk/gshell-retro-assembly/src/main/assembly/bin.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-retro-assembly/src/main/assembly/bin.xml?rev=410800&r1=410799&r2=410800&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-retro-assembly/src/main/assembly/bin.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-retro-assembly/src/main/assembly/bin.xml Thu Jun
 1 01:52:20 2006
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
-<!-- $Id: bin.xml 410172 2006-05-30 02:25:59Z jdillon $ -->
+<!-- $Id$ -->
 
 <assembly>
     <id>bin</id>

Propchange: geronimo/sandbox/gshell/trunk/gshell-retro-assembly/src/main/assembly/bin.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-retro-assembly/src/main/assembly/bin.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-retro-assembly/src/main/assembly/bin.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: geronimo/sandbox/gshell/trunk/gshell-server/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-server/pom.xml?rev=410800&r1=410799&r2=410800&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-server/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-server/pom.xml Thu Jun  1 01:52:20 2006
@@ -19,7 +19,22 @@
     <artifactId>gshell-server</artifactId>
     <name>GShell :: Server</name>
     <packaging>jar</packaging>
-    
+
+    <repositories>
+        <repository>
+            <id>module-local</id>
+            <name>Module Local Repository</name>
+            <url>file://${pom.basedir}/repository</url>
+            <layout>default</layout>
+            <releases>
+                <enabled>true</enabled>
+            </releases>
+            <snapshots>
+                <enabled>true</enabled>
+            </snapshots>
+        </repository>
+    </repositories>
+
     <dependencies>
         <dependency>
             <groupId>${pom.groupId}</groupId>
@@ -28,8 +43,26 @@
         </dependency>
 
         <dependency>
+            <groupId>commons-cli</groupId>
+            <artifactId>commons-cli</artifactId>
+        </dependency>
+
+        <!--
+
+        NOTE: May want to enhance xbean-telnet to behave like nvt4j and be more extendable
than nvt4j
+
+        <dependency>
             <groupId>org.apache.xbean</groupId>
             <artifactId>xbean-telnet</artifactId>
+        </dependency>
+        -->
+
+        <dependency>
+            <groupId>nvt4j</groupId>
+            <artifactId>nvt4j</artifactId>
+            <version>1.0a1</version>
+            <type>jar</type>
+            <scope>compile</scope>
         </dependency>
     </dependencies>
     

Added: geronimo/sandbox/gshell/trunk/gshell-server/repository/nvt4j/nvt4j/1.0a1/nvt4j-1.0a1.jar
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-server/repository/nvt4j/nvt4j/1.0a1/nvt4j-1.0a1.jar?rev=410800&view=auto
==============================================================================
Binary file - no diff available.

Propchange: geronimo/sandbox/gshell/trunk/gshell-server/repository/nvt4j/nvt4j/1.0a1/nvt4j-1.0a1.jar
------------------------------------------------------------------------------
    svn:mime-type = application/java-archive

Added: geronimo/sandbox/gshell/trunk/gshell-server/repository/nvt4j/nvt4j/maven-metadata-local.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-server/repository/nvt4j/nvt4j/maven-metadata-local.xml?rev=410800&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-server/repository/nvt4j/nvt4j/maven-metadata-local.xml
(added)
+++ geronimo/sandbox/gshell/trunk/gshell-server/repository/nvt4j/nvt4j/maven-metadata-local.xml
Thu Jun  1 01:52:20 2006
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?><metadata>
+  <groupId>nvt4j</groupId>
+  <artifactId>nvt4j</artifactId>
+  <version>1.0a1</version>
+  <versioning>
+    <versions>
+      <version>1.0a1</version>
+    </versions>
+    <lastUpdated>20060601055940</lastUpdated>
+  </versioning>
+</metadata>
\ No newline at end of file

Propchange: geronimo/sandbox/gshell/trunk/gshell-server/repository/nvt4j/nvt4j/maven-metadata-local.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-server/repository/nvt4j/nvt4j/maven-metadata-local.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-server/repository/nvt4j/nvt4j/maven-metadata-local.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: geronimo/sandbox/gshell/trunk/gshell-server/src/main/java/org/apache/geronimo/gshell/server/GShellServer.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-server/src/main/java/org/apache/geronimo/gshell/server/GShellServer.java?rev=410800&r1=410799&r2=410800&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-server/src/main/java/org/apache/geronimo/gshell/server/GShellServer.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-server/src/main/java/org/apache/geronimo/gshell/server/GShellServer.java
Thu Jun  1 01:52:20 2006
@@ -20,16 +20,19 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.gshell.GShell;
 import org.apache.geronimo.gshell.InteractiveGShell;
+import org.apache.geronimo.gshell.server.telnet.TelnetTerminal;
+import org.apache.geronimo.gshell.command.CommandException;
 import org.apache.geronimo.gshell.console.IO;
-
-import org.apache.xbean.terminal.telnet.TelnetInputStream;
-import org.apache.xbean.terminal.telnet.TelnetPrintStream;
+import org.apache.geronimo.gshell.console.Console;
+import org.apache.geronimo.gshell.console.JLineConsole;
 
 import java.net.Socket;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 
+import jline.ConsoleReader;
+
 //
 // NOTE: Some bits lifted from XBean Telnet module
 //
@@ -43,7 +46,7 @@
 {
     private static final Log log = LogFactory.getLog(GShellServer.class);
 
-    public void service(final Socket socket) throws IOException {
+    public void service(final Socket socket) throws CommandException, IOException {
         if (socket == null) {
             throw new IllegalArgumentException("Socket is null");
         }
@@ -56,13 +59,12 @@
             service(socket.getInputStream(), socket.getOutputStream());
         }
         finally {
-            if (socket != null) {
-                socket.close();
-            }
+            // Socket always non-null
+            socket.close();
         }
     }
 
-    public void service(final InputStream in, final OutputStream out) throws IOException
{
+    public void service(final InputStream in, final OutputStream out) throws CommandException,
IOException {
         if (in == null) {
             throw new IllegalArgumentException("Input is null");
         }
@@ -86,10 +88,28 @@
             // TODO: Need access to the Terminal... NVT4J
             //
 
-            io = new IO(new TelnetInputStream(in, out), new TelnetPrintStream(out));
-            GShell shell = new GShell(io);
+            TelnetTerminal term = new TelnetTerminal(in, out);
+
+            if (log.isDebugEnabled()) {
+                log.debug("Using terminal: " + term);
+                log.debug("  supported: " + term.isSupported());
+                log.debug("  height: " + term.getTerminalHeight());
+                log.debug("  width: " + term.getTerminalWidth());
+                log.debug("  echo: " + term.getEcho());
+                log.debug("  ANSI: " + term.isANSISupported());
+            }
 
-            InteractiveGShell interp = new InteractiveGShell(io, shell);
+            io = term.getIO();
+
+            //
+            // HACK: This is specific to JLine... should abstract this
+            //
+
+            ConsoleReader reader = new ConsoleReader(io.inputStream, io.out, /* bindings
*/ null, term);
+            Console console = new JLineConsole(io, reader);
+
+            GShell shell = new GShell(io);
+            InteractiveGShell interp = new InteractiveGShell(console, shell);
             interp.run();
         }
         finally {

Modified: geronimo/sandbox/gshell/trunk/gshell-server/src/main/java/org/apache/geronimo/gshell/server/ServerCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-server/src/main/java/org/apache/geronimo/gshell/server/ServerCommand.java?rev=410800&r1=410799&r2=410800&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-server/src/main/java/org/apache/geronimo/gshell/server/ServerCommand.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-server/src/main/java/org/apache/geronimo/gshell/server/ServerCommand.java
Thu Jun  1 01:52:20 2006
@@ -28,7 +28,6 @@
 import org.apache.geronimo.gshell.server.SocketServerDaemon.SocketHandler;
 
 import java.net.Socket;
-import java.io.IOException;
 
 /**
  * Starts a GShell server.
@@ -102,7 +101,7 @@
         SocketHandler handler = new SocketHandler() {
             GShellServer server = new GShellServer();
 
-            public void handle(final Socket socket) throws IOException {
+            public void handle(final Socket socket) throws Exception {
                 assert socket != null;
 
                 server.service(socket);

Modified: geronimo/sandbox/gshell/trunk/gshell-server/src/main/java/org/apache/geronimo/gshell/server/SocketServerDaemon.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-server/src/main/java/org/apache/geronimo/gshell/server/SocketServerDaemon.java?rev=410800&r1=410799&r2=410800&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-server/src/main/java/org/apache/geronimo/gshell/server/SocketServerDaemon.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-server/src/main/java/org/apache/geronimo/gshell/server/SocketServerDaemon.java
Thu Jun  1 01:52:20 2006
@@ -18,12 +18,11 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.log4j.NDC;
 
 import java.net.Socket;
 import java.net.ServerSocket;
 
-import java.io.IOException;
-
 //
 // NOTE: Some bits lifted from XBean Telnet module
 //
@@ -99,6 +98,8 @@
 
         Thread d = new Thread(threads, new Runnable() {
             public void run() {
+                NDC.push(socket.toString());
+
                 try {
                     handler.handle(socket);
                 }
@@ -107,13 +108,14 @@
                 }
                 finally {
                     try {
-                        if (socket != null) {
-                            socket.close();
-                        }
+                        // Socket always non-null
+                        socket.close();
                     }
                     catch (Throwable t) {
                         log.error("Failure while closing socket; ignoring", t);
                     }
+
+                    NDC.pop();
                 }
             }
         });
@@ -159,8 +161,8 @@
          *
          * @param socket    The client socket; never null
          *
-         * @throws IOException
+         * @throws Exception
          */
-        void handle(Socket socket) throws IOException;
+        void handle(Socket socket) throws Exception;
     }
 }

Added: geronimo/sandbox/gshell/trunk/gshell-server/src/main/java/org/apache/geronimo/gshell/server/telnet/TelnetTerminal.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-server/src/main/java/org/apache/geronimo/gshell/server/telnet/TelnetTerminal.java?rev=410800&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-server/src/main/java/org/apache/geronimo/gshell/server/telnet/TelnetTerminal.java
(added)
+++ geronimo/sandbox/gshell/trunk/gshell-server/src/main/java/org/apache/geronimo/gshell/server/telnet/TelnetTerminal.java
Thu Jun  1 01:52:20 2006
@@ -0,0 +1,154 @@
+/*
+ * 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.server.telnet;
+
+import nvt4j.impl.Terminal;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.IOException;
+
+import org.apache.geronimo.gshell.console.IO;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Telnet <a href="http://jline.sf.net">JLine</a> terminal implementation
+ * backed up by a <a href="http://www.bway.net/~lichtner/nvt4j.html">NVT4J</a>
terminal instance.
+ *
+ * @version $Id$
+ */
+public class TelnetTerminal
+    extends jline.Terminal
+{
+    private static final Log log = LogFactory.getLog(TelnetTerminal.class);
+
+    private final Terminal term;
+
+    private final IO io;
+
+    public TelnetTerminal(final InputStream input, final OutputStream output) throws IOException
{
+        this.term = new Terminal(input, output);
+        this.io =  new IO(createInputStream(), createOutputStream());
+    }
+
+    public void initializeTerminal() throws Exception {
+        //
+        // NVT4j does all init in Terminal.init() which is called from constructor
+        //
+    }
+
+    public int getTerminalWidth() {
+        return term.getColumns();
+    }
+
+    public int getTerminalHeight() {
+        return term.getRows();
+    }
+
+    public boolean isSupported() {
+        return true;
+    }
+
+    public boolean getEcho() {
+        return false;
+    }
+
+    private InputStream createInputStream() {
+        return new InputStream() {
+            public int read() throws IOException {
+                return term.get();
+            }
+        };
+    }
+
+    private OutputStream createOutputStream() {
+        return new OutputStream() {
+            public void write(final int i) throws IOException {
+                term.put(i);
+            }
+        };
+    }
+
+    public IO getIO() {
+        return io;
+    }
+
+    //
+    // NOTE: Copied (and modified) from jline.UnixTerminal
+    //
+
+    public static final short ARROW_START = 27;
+
+    public static final short ARROW_PREFIX = 91;
+
+    public static final short ARROW_LEFT = 68;
+
+    public static final short ARROW_RIGHT = 67;
+
+    public static final short ARROW_UP = 65;
+
+    public static final short ARROW_DOWN = 66;
+
+    public static final short HOME_CODE = 72;
+
+    public static final short END_CODE = 70;
+
+    public int readVirtualKey(final InputStream in) throws IOException {
+        assert in != null;
+
+        int c = readCharacter(in);
+
+        //
+        // TODO: Need to check if this is correct... arrow handling is a tad off
+        //
+
+        // in Unix terminals, arrow keys are represented by
+        // a sequence of 3 characters. E.g., the up arrow
+        // key yields 27, 91, 68
+
+        if (c == ARROW_START) {
+            c = readCharacter(in);
+
+            if (c == ARROW_PREFIX) {
+                c = readCharacter(in);
+
+                switch (c) {
+                    case ARROW_UP:
+                        return CTRL_P;
+
+                    case ARROW_DOWN:
+                        return CTRL_N;
+
+                    case ARROW_LEFT:
+                        return CTRL_B;
+
+                    case ARROW_RIGHT:
+                        return CTRL_F;
+
+                    case HOME_CODE:
+                        return CTRL_A;
+
+                    case END_CODE:
+                        return CTRL_E;
+                }
+            }
+        }
+
+        return c;
+    }
+}

Propchange: geronimo/sandbox/gshell/trunk/gshell-server/src/main/java/org/apache/geronimo/gshell/server/telnet/TelnetTerminal.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-server/src/main/java/org/apache/geronimo/gshell/server/telnet/TelnetTerminal.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-server/src/main/java/org/apache/geronimo/gshell/server/telnet/TelnetTerminal.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message