felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r830725 - in /felix/trunk/karaf: client/pom.xml client/src/main/java/org/apache/felix/karaf/client/Main.java shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/ShellFactoryImpl.java
Date Wed, 28 Oct 2009 18:59:18 GMT
Author: gnodet
Date: Wed Oct 28 18:59:18 2009
New Revision: 830725

URL: http://svn.apache.org/viewvc?rev=830725&view=rev
Log:
FELIX-1818: Ctrl-C kills the karaf-client instead of being sent to the server

Modified:
    felix/trunk/karaf/client/pom.xml
    felix/trunk/karaf/client/src/main/java/org/apache/felix/karaf/client/Main.java
    felix/trunk/karaf/shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/ShellFactoryImpl.java

Modified: felix/trunk/karaf/client/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/client/pom.xml?rev=830725&r1=830724&r2=830725&view=diff
==============================================================================
--- felix/trunk/karaf/client/pom.xml (original)
+++ felix/trunk/karaf/client/pom.xml Wed Oct 28 18:59:18 2009
@@ -46,6 +46,10 @@
             <artifactId>sshd-core</artifactId>
         </dependency>
         <dependency>
+            <groupId>org.apache.felix.karaf.shell</groupId>
+            <artifactId>org.apache.felix.karaf.shell.console</artifactId>
+        </dependency>
+        <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
         </dependency>

Modified: felix/trunk/karaf/client/src/main/java/org/apache/felix/karaf/client/Main.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/client/src/main/java/org/apache/felix/karaf/client/Main.java?rev=830725&r1=830724&r2=830725&view=diff
==============================================================================
--- felix/trunk/karaf/client/src/main/java/org/apache/felix/karaf/client/Main.java (original)
+++ felix/trunk/karaf/client/src/main/java/org/apache/felix/karaf/client/Main.java Wed Oct
28 18:59:18 2009
@@ -17,7 +17,10 @@
 package org.apache.felix.karaf.client;
 
 import java.io.ByteArrayInputStream;
+import java.io.PrintWriter;
 
+import jline.Terminal;
+import org.apache.felix.karaf.shell.console.jline.TerminalFactory;
 import org.apache.sshd.ClientChannel;
 import org.apache.sshd.ClientSession;
 import org.apache.sshd.SshClient;
@@ -71,6 +74,7 @@
         // TODO: implement sending a direct command
 
         SshClient client = null;
+        Terminal terminal = null;
         try {
             client = SshClient.setUpDefaultClient();
             client.start();
@@ -83,8 +87,12 @@
  				channel = session.createChannel("exec");
 	            channel.setIn(new ByteArrayInputStream(sb.append("\n").toString().getBytes()));
 			} else {
+                terminal = new TerminalFactory().getTerminal();
  				channel = session.createChannel("shell");
-	            channel.setIn(new ConsoleReader().getInput());
+                ConsoleReader reader = new ConsoleReader(System.in, new PrintWriter(System.out),
+                                                TerminalFactory.class.getResourceAsStream("keybinding.properties"),
+                                                terminal);
+	            channel.setIn(reader.getInput());
 			}
             channel.setOut(System.out);
             channel.setErr(System.err);
@@ -97,6 +105,11 @@
             try {
                 client.stop();
             } catch (Throwable t) { }
+            try {
+                if (terminal != null) {
+                    terminal.restoreTerminal();
+                }
+            } catch (Throwable t) { }
         }
         System.exit(0);
     }

Modified: felix/trunk/karaf/shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/ShellFactoryImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/karaf/shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/ShellFactoryImpl.java?rev=830725&r1=830724&r2=830725&view=diff
==============================================================================
--- felix/trunk/karaf/shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/ShellFactoryImpl.java
(original)
+++ felix/trunk/karaf/shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/ShellFactoryImpl.java
Wed Oct 28 18:59:18 2009
@@ -94,8 +94,8 @@
                 };
                 Console console = new Console(commandProcessor,
                                               in,
-                                              new PrintStream(out),
-                                              new PrintStream(err),
+                                              new PrintStream(out, true),
+                                              new PrintStream(err, true),
                                               new SshTerminal(env),
                                               new AggregateCompleter(completers),
                                               new Runnable() {



Mime
View raw message