geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r411026 - in /geronimo/sandbox/gshell/trunk: gshell-assemblies/gshell-assembly/ gshell-core/src/main/java/org/apache/geronimo/gshell/console/ gshell-server/ gshell-server/gshell-server-core/ gshell-server/gshell-server-core/src/main/java/or...
Date Fri, 02 Jun 2006 04:09:17 GMT
Author: jdillon
Date: Thu Jun  1 21:09:16 2006
New Revision: 411026

URL: http://svn.apache.org/viewvc?rev=411026&view=rev
Log:
Split off Telnet bits from the server core

Added:
    geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-telnet/src/main/java/org/apache/geronimo/gshell/server/telnet/ConsoleFactoryImpl.java
  (with props)
    geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-telnet/src/main/resources/META-INF/org.apache.geronimo.gshell.console.ConsoleFactory/
      - copied from r411022, geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-telnet/src/main/resources/META-INF/org.apache.geronimo.gshell.command/
    geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-telnet/src/main/resources/META-INF/org.apache.geronimo.gshell.console.ConsoleFactory/telnet
Removed:
    geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-core/src/main/java/org/apache/geronimo/gshell/server/telnet/
    geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-telnet/src/main/java/org/apache/geronimo/gshell/server/GShellServer.java
    geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-telnet/src/main/java/org/apache/geronimo/gshell/server/ServerCommand.java
    geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-telnet/src/main/java/org/apache/geronimo/gshell/server/SocketServerDaemon.java
    geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-telnet/src/main/resources/META-INF/org.apache.geronimo.gshell.command/
    geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-telnet/src/main/resources/META-INF/org.apache.geronimo.gshell.console.ConsoleFactory/server.properties
Modified:
    geronimo/sandbox/gshell/trunk/gshell-assemblies/gshell-assembly/pom.xml
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/Console.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/ConsoleFactory.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/JLineConsole.java
    geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/SimpleConsole.java
    geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-core/pom.xml
    geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-core/src/main/java/org/apache/geronimo/gshell/server/GShellServer.java
    geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-telnet/pom.xml
    geronimo/sandbox/gshell/trunk/gshell-server/pom.xml

Modified: geronimo/sandbox/gshell/trunk/gshell-assemblies/gshell-assembly/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-assemblies/gshell-assembly/pom.xml?rev=411026&r1=411025&r2=411026&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-assemblies/gshell-assembly/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-assemblies/gshell-assembly/pom.xml Thu Jun  1 21:09:16
2006
@@ -35,10 +35,16 @@
 
         <dependency>
             <groupId>${pom.groupId}</groupId>
-            <artifactId>gshell-server</artifactId>
+            <artifactId>gshell-server-core</artifactId>
             <version>${pom.version}</version>
         </dependency>
-        
+
+        <dependency>
+            <groupId>${pom.groupId}</groupId>
+            <artifactId>gshell-server-telnet</artifactId>
+            <version>${pom.version}</version>
+        </dependency>
+
         <dependency>
             <groupId>${pom.groupId}</groupId>
             <artifactId>standard-commands</artifactId>

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=411026&r1=411025&r2=411026&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
Thu Jun  1 21:09:16 2006
@@ -28,4 +28,6 @@
 public interface Console
 {
     String readLine(final String prompt) throws IOException;
+
+    IO getIO();
 }

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/ConsoleFactory.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/ConsoleFactory.java?rev=411026&r1=411025&r2=411026&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/ConsoleFactory.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/ConsoleFactory.java
Thu Jun  1 21:09:16 2006
@@ -16,6 +16,9 @@
 
 package org.apache.geronimo.gshell.console;
 
+import java.io.InputStream;
+import java.io.OutputStream;
+
 /**
  * Interface to abstract creation of {@link Console} instances.
  *
@@ -28,9 +31,5 @@
     //       (like the script command) with out needing to know which is the right flavor
     //
 
-    //
-    // TODO: Re-eval if this needs to be an interface... might not
-    //
-
-    Console create(IO io) throws Exception;
+    Console create(InputStream input, OutputStream output) throws Exception;
 }

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=411026&r1=411025&r2=411026&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 21:09:16 2006
@@ -52,7 +52,7 @@
         if (io == null) {
             throw new IllegalArgumentException("IO is null");
         }
-        
+
         this.io = io;
         this.reader = new ConsoleReader(io.inputStream, io.out);
     }
@@ -61,6 +61,10 @@
         assert prompt != null;
 
         return reader.readLine(prompt);
+    }
+
+    public IO getIO() {
+        return io;
     }
 
     public ConsoleReader getReader() {

Modified: geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/SimpleConsole.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/SimpleConsole.java?rev=411026&r1=411025&r2=411026&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/SimpleConsole.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-core/src/main/java/org/apache/geronimo/gshell/console/SimpleConsole.java
Thu Jun  1 21:09:16 2006
@@ -54,6 +54,10 @@
         return reader.readLine();
     }
 
+    public IO getIO() {
+        return io;
+    }
+
     public BufferedReader getReader() {
         return reader;
     }

Modified: geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-core/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-core/pom.xml?rev=411026&r1=411025&r2=411026&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-core/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-core/pom.xml Thu Jun  1 21:09:16
2006
@@ -26,25 +26,10 @@
             <artifactId>gshell-core</artifactId>
             <version>${pom.version}</version>
         </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>
         </dependency>
     </dependencies>
     

Modified: geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-core/src/main/java/org/apache/geronimo/gshell/server/GShellServer.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-core/src/main/java/org/apache/geronimo/gshell/server/GShellServer.java?rev=411026&r1=411025&r2=411026&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-core/src/main/java/org/apache/geronimo/gshell/server/GShellServer.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-core/src/main/java/org/apache/geronimo/gshell/server/GShellServer.java
Thu Jun  1 21:09:16 2006
@@ -20,16 +20,18 @@
 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.geronimo.gshell.console.Console;
 import org.apache.geronimo.gshell.console.JLineConsole;
+import org.apache.geronimo.gshell.console.ConsoleFactory;
+import org.apache.xbean.finder.ResourceFinder;
 
 import java.net.Socket;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.util.Map;
 
 import jline.ConsoleReader;
 
@@ -46,6 +48,26 @@
 {
     private static final Log log = LogFactory.getLog(GShellServer.class);
 
+    private final ConsoleFactory consoleFactory;
+
+    public GShellServer() throws Exception {
+        ResourceFinder resourceFinder = new ResourceFinder("META-INF");
+        Map<String, Class> resourcesMap = resourceFinder.mapAvailableImplementations(java.net.URLStreamHandler.class);
+        String typename = "telnet";
+
+        Class type = resourcesMap.get(typename);
+        if (type == null) {
+            throw new CommandException("Could not load ConsoleFactory of type: " + typename);
+        }
+
+        try {
+            this.consoleFactory = (ConsoleFactory)type.newInstance();
+        }
+        catch (Exception e) {
+            throw new CommandException("Failed to create ConsoleFactory of type: " + typename,
e);
+        }
+    }
+
     public void service(final Socket socket) throws CommandException, IOException {
         if (socket == null) {
             throw new IllegalArgumentException("Socket is null");
@@ -64,53 +86,29 @@
         }
     }
 
-    public void service(final InputStream in, final OutputStream out) throws CommandException,
IOException {
-        if (in == null) {
+    public void service(final InputStream input, final OutputStream output) throws CommandException,
IOException {
+        if (input == null) {
             throw new IllegalArgumentException("Input is null");
         }
-        if (out == null) {
+        if (output == null) {
             throw new IllegalArgumentException("Output is null");
         }
 
-        IO io = null;
-
         //
         // TODO: Need to figure out how to get the logging stream for this GShell to use
         //       the given IO streams
         //
 
+        IO io = null;
         try {
-            //
-            // TODO: Abstract Telnet specifics; support other protocols (ie. SSH)
-            //
-
-            //
-            // TODO: Need access to the Terminal... NVT4J
-            //
-
-            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());
-            }
-
-            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);
-
+            Console console = consoleFactory.create(input, output);
+            io = console.getIO();
             GShell shell = new GShell(io);
             InteractiveGShell interp = new InteractiveGShell(console, shell);
             interp.run();
+        }
+        catch (Exception e) {
+            throw new CommandException(e);
         }
         finally {
             if (io != null) {

Modified: geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-telnet/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-telnet/pom.xml?rev=411026&r1=411025&r2=411026&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-telnet/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-telnet/pom.xml Thu Jun  1 21:09:16
2006
@@ -16,14 +16,20 @@
         <relativePath>../pom.xml</relativePath>
     </parent>
     
-    <artifactId>gshell-server-core</artifactId>
-    <name>GShell Server :: Core</name>
+    <artifactId>gshell-server-telnet</artifactId>
+    <name>GShell Server :: Telnet</name>
     <packaging>jar</packaging>
 
     <dependencies>
         <dependency>
             <groupId>${pom.groupId}</groupId>
             <artifactId>gshell-core</artifactId>
+            <version>${pom.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>${pom.groupId}</groupId>
+            <artifactId>gshell-server-core</artifactId>
             <version>${pom.version}</version>
         </dependency>
 

Added: geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-telnet/src/main/java/org/apache/geronimo/gshell/server/telnet/ConsoleFactoryImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-telnet/src/main/java/org/apache/geronimo/gshell/server/telnet/ConsoleFactoryImpl.java?rev=411026&view=auto
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-telnet/src/main/java/org/apache/geronimo/gshell/server/telnet/ConsoleFactoryImpl.java
(added)
+++ geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-telnet/src/main/java/org/apache/geronimo/gshell/server/telnet/ConsoleFactoryImpl.java
Thu Jun  1 21:09:16 2006
@@ -0,0 +1,65 @@
+/*
+ * 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 org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.gshell.console.ConsoleFactory;
+import org.apache.geronimo.gshell.console.Console;
+import org.apache.geronimo.gshell.console.IO;
+import org.apache.geronimo.gshell.console.JLineConsole;
+import jline.ConsoleReader;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * ???
+ *
+ * @version $Id$
+ */
+public class ConsoleFactoryImpl
+    implements ConsoleFactory
+{
+    private static final Log log = LogFactory.getLog(ConsoleFactoryImpl.class);
+
+    public Console create(final InputStream in, final OutputStream out) throws Exception
{
+        if (in == null) {
+            throw new IllegalArgumentException("Input is null");
+        }
+        if (out == null) {
+            throw new IllegalArgumentException("Output is null");
+        }
+
+        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());
+        }
+
+        IO io = term.getIO();
+        ConsoleReader reader = new ConsoleReader(io.inputStream, io.out, /* bindings */ null,
term);
+        Console console = new JLineConsole(io, reader);
+
+        return console;
+    }
+}
\ No newline at end of file

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

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

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

Added: geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-telnet/src/main/resources/META-INF/org.apache.geronimo.gshell.console.ConsoleFactory/telnet
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-server/gshell-server-telnet/src/main/resources/META-INF/org.apache.geronimo.gshell.console.ConsoleFactory/telnet?rev=411026&view=auto
==============================================================================
    (empty)

Modified: geronimo/sandbox/gshell/trunk/gshell-server/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-server/pom.xml?rev=411026&r1=411025&r2=411026&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-server/pom.xml (original)
+++ geronimo/sandbox/gshell/trunk/gshell-server/pom.xml Thu Jun  1 21:09:16 2006
@@ -22,6 +22,7 @@
     
     <modules>
         <module>gshell-server-core</module>
+        <module>gshell-server-telnet</module>
     </modules>
     
 </project>



Mime
View raw message