[maven-release-plugin]  copy for tag karaf-2.2.6

git-svn-id: https://svn.apache.org/repos/asf/karaf/tags/karaf-2.2.6@1309443 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/shell/console/src/main/java/org/apache/karaf/shell/console/jline/ConsoleFactory.java b/shell/console/src/main/java/org/apache/karaf/shell/console/jline/ConsoleFactory.java
index 573b0e7..db23c1e 100644
--- a/shell/console/src/main/java/org/apache/karaf/shell/console/jline/ConsoleFactory.java
+++ b/shell/console/src/main/java/org/apache/karaf/shell/console/jline/ConsoleFactory.java
@@ -78,8 +78,31 @@
         }
     }
 
+    public static Object invokePrivateMethod(Object o, String methodName, Object[] params) throws Exception {
+        final Method methods[] = o.getClass().getDeclaredMethods();
+        for (int i = 0; i < methods.length; ++i) {
+            if (methodName.equals(methods[i].getName())) {
+                methods[i].setAccessible(true);
+                return methods[i].invoke(o, params);
+            }
+        }
+        return null;
+    }
+    
+    private static <T> T unwrapBIS(T stream) {
+        try {
+             return (T) invokePrivateMethod(stream, "getInIfOpen", null);
+        } catch (Throwable t) {
+             return stream;
+        }
+    }
+
     protected void doStart(String user) throws Exception {
-        InputStream in = unwrap(System.in);
+        final Terminal terminal = terminalFactory.getTerminal();
+        // unwrap stream so it can be recognized by the terminal and wrapped to get 
+        // special keys in windows
+        InputStream unwrappedIn = unwrapBIS(unwrap(System.in));
+        InputStream in = terminal.wrapInIfNeeded(unwrappedIn);
         PrintStream out = unwrap(System.out);
         PrintStream err = unwrap(System.err);
         Runnable callback = new Runnable() {
@@ -91,7 +114,6 @@
                 }
             }
         };
-        final Terminal terminal = terminalFactory.getTerminal();
         this.console = new Console(commandProcessor,
                                    in,
                                    wrap(out),