Upgrade to latest sshd snapshot

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@835869 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/karaf/shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/ShellCommandFactory.java b/karaf/shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/ShellCommandFactory.java
index 4e0c290..4822347 100644
--- a/karaf/shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/ShellCommandFactory.java
+++ b/karaf/shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/ShellCommandFactory.java
@@ -24,7 +24,10 @@
 import java.io.OutputStream;
 import java.io.PrintStream;
 
+import org.apache.sshd.server.Command;
 import org.apache.sshd.server.CommandFactory;
+import org.apache.sshd.server.Environment;
+import org.apache.sshd.server.ExitCallback;
 import org.osgi.service.command.CommandProcessor;
 import org.osgi.service.command.CommandSession;
 
@@ -68,7 +71,7 @@
             this.callback = callback;
         }
 
-        public void start() throws IOException {
+        public void start(final Environment env) throws IOException {
             try {
                 CommandSession session = commandProcessor.createSession(in, new PrintStream(out), new PrintStream(err));
                 session.execute(command);
@@ -80,6 +83,9 @@
             }
         }
 
+        public void destroy() {
+		}
+
     }
 
     private static void close(Closeable... closeables) {
diff --git a/karaf/shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/ShellFactoryImpl.java b/karaf/shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/ShellFactoryImpl.java
index 3fc44ee..5c94585 100644
--- a/karaf/shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/ShellFactoryImpl.java
+++ b/karaf/shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/ShellFactoryImpl.java
@@ -26,21 +26,26 @@
 import java.io.PrintStream;
 import java.util.List;
 import java.util.Map;
+import java.util.Properties;
 import java.util.concurrent.Callable;
 
 import org.apache.felix.karaf.shell.console.Completer;
 import org.apache.felix.karaf.shell.console.completer.AggregateCompleter;
 import org.apache.felix.karaf.shell.console.jline.Console;
-import org.apache.sshd.server.ShellFactory;
+import org.apache.sshd.common.Factory;
+import org.apache.sshd.server.Command;
+import org.apache.sshd.server.Environment;
+import org.apache.sshd.server.ExitCallback;
+import org.osgi.service.blueprint.container.ReifiedType;
 import org.osgi.service.command.CommandProcessor;
 import org.osgi.service.command.CommandSession;
 
 /**
- * SSHD {@link org.apache.sshd.server.ShellFactory} which provides access to Shell.
+ * SSHD {@link org.apache.sshd.server.Command} factory which provides access to Shell.
  *
  * @version $Rev: 731517 $ $Date: 2009-01-05 11:25:19 +0100 (Mon, 05 Jan 2009) $
  */
-public class ShellFactoryImpl implements ShellFactory
+public class ShellFactoryImpl implements Factory<Command>
 {
     private CommandProcessor commandProcessor;
     private List<Completer> completers;
@@ -53,11 +58,11 @@
         this.completers = completers;
     }
 
-    public Shell createShell() {
+    public Command create() {
         return new ShellImpl();
     }
 
-    public class ShellImpl implements Shell
+    public class ShellImpl implements Command
     {
         private InputStream in;
 
@@ -135,4 +140,21 @@
         }
     }
 
+    public static Converter getConverter() {
+        return new Converter();
+    }
+
+    public static class Converter implements org.osgi.service.blueprint.container.Converter {
+
+        public boolean canConvert(Object sourceObject, ReifiedType targetType) {
+            return ShellFactoryImpl.class.isAssignableFrom(sourceObject.getClass())
+                    && Factory.class.equals(targetType.getRawClass())
+                    && Command.class.equals(targetType.getActualTypeArgument(0).getRawClass());
+        }
+
+        public Object convert(Object sourceObject, ReifiedType targetType) throws Exception {
+            return sourceObject;
+        }
+    }
+
 }
diff --git a/karaf/shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/SshTerminal.java b/karaf/shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/SshTerminal.java
index e42da15..9c4d42f 100644
--- a/karaf/shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/SshTerminal.java
+++ b/karaf/shell/ssh/src/main/java/org/apache/felix/karaf/shell/ssh/SshTerminal.java
@@ -24,10 +24,11 @@
 
 import jline.Terminal;
 import org.apache.sshd.common.PtyMode;
-import org.apache.sshd.server.ShellFactory;
+import org.apache.sshd.server.Environment;
 import org.apache.sshd.server.Signal;
+import org.apache.sshd.server.SignalListener;
 
-public class SshTerminal extends Terminal implements ShellFactory.SignalListener {
+public class SshTerminal extends Terminal implements SignalListener {
 
     public static final short ARROW_START = 27;
     public static final short ARROW_PREFIX = 91;
@@ -42,14 +43,14 @@
     public static final short DEL_THIRD = 51;
     public static final short DEL_SECOND = 126;
 
-    private ShellFactory.Environment environment;
+    private Environment environment;
     private boolean backspaceDeleteSwitched = false;
     private String encoding = System.getProperty("input.encoding", "UTF-8");
     private ReplayPrefixOneCharInputStream replayStream = new ReplayPrefixOneCharInputStream(encoding);
     private InputStreamReader replayReader;
     private boolean isWindowsTerminal;
 
-    public SshTerminal(ShellFactory.Environment environment) {
+    public SshTerminal(Environment environment) {
         this.environment = environment;
         this.environment.addSignalListener(this);
         try {
@@ -74,11 +75,11 @@
     }
 
     public int getTerminalWidth() {
-        return Integer.valueOf(this.environment.getEnv().get(ShellFactory.Environment.ENV_COLUMNS));
+        return Integer.valueOf(this.environment.getEnv().get(Environment.ENV_COLUMNS));
     }
 
     public int getTerminalHeight() {
-        return Integer.valueOf(this.environment.getEnv().get(ShellFactory.Environment.ENV_LINES));
+        return Integer.valueOf(this.environment.getEnv().get(Environment.ENV_LINES));
     }
 
     public boolean isSupported() {
diff --git a/karaf/shell/ssh/src/main/resources/OSGI-INF/blueprint/shell-ssh.xml b/karaf/shell/ssh/src/main/resources/OSGI-INF/blueprint/shell-ssh.xml
index 10c0439..545d769 100644
--- a/karaf/shell/ssh/src/main/resources/OSGI-INF/blueprint/shell-ssh.xml
+++ b/karaf/shell/ssh/src/main/resources/OSGI-INF/blueprint/shell-ssh.xml
@@ -23,6 +23,10 @@
            xmlns:ext="http://geronimo.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0"
            default-activation="lazy">
 
+    <type-converters>
+        <bean class="org.apache.felix.karaf.shell.ssh.ShellFactoryImpl" factory-method="getConverter" />
+    </type-converters>
+
     <ext:property-placeholder placeholder-prefix="$[" placeholder-suffix="]"/>
 
     <cm:property-placeholder persistent-id="org.apache.felix.karaf.shell">