You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by gn...@apache.org on 2014/03/05 16:08:30 UTC

[08/10] [KARAF-2805] Migrate shell, ssh, wrapper, kar, instance, features and bundle to the new API and switch the bin/shell script to use the new console

http://git-wip-us.apache.org/repos/asf/karaf/blob/2e2b9324/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/IfAction.java
----------------------------------------------------------------------
diff --git a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/IfAction.java b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/IfAction.java
index 6a01233..b7d4585 100644
--- a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/IfAction.java
+++ b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/IfAction.java
@@ -16,18 +16,20 @@
  */
 package org.apache.karaf.shell.commands.impl;
 
-import org.apache.felix.service.command.Function;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.console.AbstractAction;
-import org.apache.karaf.shell.inject.Service;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.karaf.shell.api.console.Function;
+import org.apache.karaf.shell.api.console.Session;
 
 /**
  * Execute a closure on a list of arguments.
  */
 @Command(scope = "shell", name = "if", description = "If/Then/Else block.")
 @Service
-public class IfAction extends AbstractAction {
+public class IfAction implements Action {
 
     @Argument(name = "condition", index = 0, multiValued = false, required = true, description = "The condition")
     Function condition;
@@ -38,8 +40,11 @@ public class IfAction extends AbstractAction {
     @Argument(name = "ifFalse", index = 2, multiValued = false, required = false, description = "The function to execute if the condition is false")
     Function ifFalse;
 
+    @Reference
+    Session session;
+
     @Override
-    protected Object doExecute() throws Exception {
+    public Object execute() throws Exception {
         Object result = condition.execute(session, null);
         if (isTrue(result)) {
             return ifTrue.execute(session, null);

http://git-wip-us.apache.org/repos/asf/karaf/blob/2e2b9324/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/InfoAction.java
----------------------------------------------------------------------
diff --git a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/InfoAction.java b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/InfoAction.java
index 90cf2e8..dfa811d 100644
--- a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/InfoAction.java
+++ b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/InfoAction.java
@@ -31,26 +31,33 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Properties;
+import java.util.concurrent.Callable;
 
-import org.apache.karaf.shell.commands.Command;
 import org.apache.karaf.shell.commands.InfoProvider;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.apache.karaf.shell.inject.Service;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
 import org.fusesource.jansi.Ansi;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
 
 @Command(scope = "shell", name = "info", description = "Prints system information.")
 @Service
-public class InfoAction extends OsgiCommandSupport {
+public class InfoAction implements Action {
 
     private NumberFormat fmtI = new DecimalFormat("###,###", new DecimalFormatSymbols(Locale.ENGLISH));
     private NumberFormat fmtD = new DecimalFormat("###,##0.000", new DecimalFormatSymbols(Locale.ENGLISH));
 
-    protected Object doExecute() throws Exception {
+//    @Reference
+    List<InfoProvider> infoProviders;
+
+    @Override
+    public Object execute() throws Exception {
         int maxNameLen;
 
         RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
@@ -67,8 +74,10 @@ public class InfoAction extends OsgiCommandSupport {
         printValue("Karaf version", maxNameLen, System.getProperty("karaf.version"));
         printValue("Karaf home", maxNameLen, System.getProperty("karaf.home"));
         printValue("Karaf base", maxNameLen, System.getProperty("karaf.base"));
-        printValue("OSGi Framework", maxNameLen, bundleContext.getBundle(0).getSymbolicName() + " - " +
-                bundleContext.getBundle(0).getVersion());
+        String osgi = getOsgiFramework();
+        if (osgi != null) {
+            printValue("OSGi Framework", maxNameLen, osgi);
+        }
         System.out.println();
 
         System.out.println("JVM");
@@ -119,9 +128,7 @@ public class InfoAction extends OsgiCommandSupport {
 
         //Display Information from external information providers.
         Map<String, Map<Object, Object>> properties = new HashMap<String, Map<Object, Object>>();
-        List<InfoProvider> infoProviders = getAllServices(InfoProvider.class);
         if (infoProviders != null) {
-
             // dump all properties to Map, KARAF-425
             for (InfoProvider provider : infoProviders) {
                 if (!properties.containsKey(provider.getName())) {
@@ -149,7 +156,6 @@ public class InfoAction extends OsgiCommandSupport {
                 }
             }
         }
-
         return null;
     }
 
@@ -221,4 +227,21 @@ public class InfoAction extends OsgiCommandSupport {
         return sb.toString();
     }
 
+    String getOsgiFramework() {
+        try {
+            Callable<String> call = new Callable<String>() {
+                @Override
+                public String call() throws Exception {
+                    BundleContext context = FrameworkUtil.getBundle(getClass()).getBundleContext();
+                    Bundle sysBundle = context.getBundle(0);
+                    return sysBundle.getSymbolicName() + "-" + sysBundle.getVersion();
+                }
+            };
+            return call.call();
+        } catch (Throwable t) {
+            // We're not in OSGi, just safely return null
+            return null;
+        }
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/karaf/blob/2e2b9324/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/JavaAction.java
----------------------------------------------------------------------
diff --git a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/JavaAction.java b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/JavaAction.java
index 84e4d62..99f201d 100644
--- a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/JavaAction.java
+++ b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/JavaAction.java
@@ -19,11 +19,13 @@ package org.apache.karaf.shell.commands.impl;
 import java.lang.reflect.Method;
 import java.util.List;
 
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.apache.karaf.shell.console.AbstractAction;
-import org.apache.karaf.shell.inject.Service;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Execute a Java standard application.
@@ -34,7 +36,9 @@ import org.apache.karaf.shell.inject.Service;
  */
 @Command(scope = "shell", name = "java", description = "Executes a Java standard application.")
 @Service
-public class JavaAction extends AbstractAction {
+public class JavaAction implements Action {
+
+    private final Logger log = LoggerFactory.getLogger(getClass());
 
     @Option(name = "-m", aliases = {"--method"}, description = "Invoke a named method", required = false, multiValued = false)
     private String methodName = "main";
@@ -45,7 +49,8 @@ public class JavaAction extends AbstractAction {
     @Argument(index = 1, name = "arguments", description="Arguments to pass to the method of the given class", required = false, multiValued = false)
     private List<String> args;
 
-    protected Object doExecute() throws Exception {
+    @Override
+    public Object execute() throws Exception {
         boolean info = log.isInfoEnabled();
 
         Class type = Thread.currentThread().getContextClassLoader().loadClass(className);

http://git-wip-us.apache.org/repos/asf/karaf/blob/2e2b9324/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/LogoutAction.java
----------------------------------------------------------------------
diff --git a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/LogoutAction.java b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/LogoutAction.java
index f11437d..3654225 100644
--- a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/LogoutAction.java
+++ b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/LogoutAction.java
@@ -16,18 +16,28 @@
  */
 package org.apache.karaf.shell.commands.impl;
 
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.console.AbstractAction;
-import org.apache.karaf.shell.console.CloseShellException;
-import org.apache.karaf.shell.inject.Service;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.karaf.shell.api.console.Session;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 @Command(scope = "shell", name = "logout", description = "Disconnects shell from current session.")
 @Service
-public class LogoutAction extends AbstractAction {
+public class LogoutAction implements Action {
 
-    protected Object doExecute() throws Exception {
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    @Reference
+    Session session;
+
+    @Override
+    public Object execute() throws Exception {
         log.info("Disconnecting from current session...");
-        throw new CloseShellException();
+        session.close();
+        return null;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/karaf/blob/2e2b9324/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/MoreAction.java
----------------------------------------------------------------------
diff --git a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/MoreAction.java b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/MoreAction.java
index ebe1d86..5db87f6 100644
--- a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/MoreAction.java
+++ b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/MoreAction.java
@@ -24,23 +24,34 @@ import java.lang.reflect.Method;
 import java.util.LinkedList;
 import java.util.List;
 
-import jline.Terminal;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.apache.karaf.shell.console.AbstractAction;
-import org.apache.karaf.shell.inject.Service;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.console.Session;
+import org.apache.karaf.shell.api.console.Terminal;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 @Command(scope = "shell", name = "more", description = "File pager.")
 @Service
-public class MoreAction extends AbstractAction {
+public class MoreAction implements Action {
+
+    private final Logger log = LoggerFactory.getLogger(getClass());
 
     @Option(name = "--lines", description = "stop after N lines")
     int lines;
 
+    @Reference
+    Terminal terminal;
+
+    @Reference
+    Session session;
+
     @Override
-    protected Object doExecute() throws Exception {
-        Terminal term = (Terminal) session.get(".jline.terminal");
-        if (term == null || !isTty(System.out)) {
+    public Object execute() throws Exception {
+        if (terminal == null || !isTty(System.out)) {
             BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
             String line;
             while ((line = reader.readLine()) != null) {
@@ -49,13 +60,13 @@ public class MoreAction extends AbstractAction {
             }
             return null;
         } else {
-            boolean echo = term.isEchoEnabled();
-            term.setEchoEnabled(false);
+            boolean echo = terminal.isEchoEnabled();
+            terminal.setEchoEnabled(false);
             try {
                 if (lines == 0) {
-                    lines = term.getHeight();
+                    lines = terminal.getHeight();
                 }
-                LineSplitter reader = new LineSplitter(new BufferedReader(new InputStreamReader(System.in)), term.getWidth());
+                LineSplitter reader = new LineSplitter(new BufferedReader(new InputStreamReader(System.in)), terminal.getWidth());
                 int count = 0;
                 int c;
                 do {
@@ -100,14 +111,13 @@ public class MoreAction extends AbstractAction {
                         }
                     }
                 } while (c != 'q');
-                return null;
             } catch (InterruptedException ie) {
-            	log.debug("Interupted by user");
-            	return null;
+            	log.debug("Interrupted by user");
             } finally {
-                term.setEchoEnabled(echo);
+                terminal.setEchoEnabled(echo);
             }
         }
+        return null;
     }
 
     public static class LineSplitter {
@@ -148,4 +158,16 @@ public class MoreAction extends AbstractAction {
         }
     }
 
+    /**
+     * This is for long running commands to be interrupted by ctrl-c
+     *
+     * @throws InterruptedException
+     */
+    public static void checkInterrupted() throws InterruptedException {
+        Thread.yield();
+        if (Thread.currentThread().isInterrupted()) {
+            throw new InterruptedException();
+        }
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/karaf/blob/2e2b9324/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/NewAction.java
----------------------------------------------------------------------
diff --git a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/NewAction.java b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/NewAction.java
index 990eee5..c2d2a86 100644
--- a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/NewAction.java
+++ b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/NewAction.java
@@ -16,14 +16,6 @@
  */
 package org.apache.karaf.shell.commands.impl;
 
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.converter.DefaultConverter;
-import org.apache.karaf.shell.commands.converter.GenericType;
-import org.apache.karaf.shell.commands.converter.ReifiedType;
-import org.apache.karaf.shell.console.AbstractAction;
-import org.apache.karaf.shell.inject.Service;
-
 import java.lang.reflect.Array;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
@@ -36,12 +28,20 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.karaf.shell.support.converter.DefaultConverter;
+import org.apache.karaf.shell.support.converter.GenericType;
+import org.apache.karaf.shell.support.converter.ReifiedType;
+
 /**
  * Instantiate a new object
  */
 @Command(scope = "shell", name = "new", description = "Creates a new java object.")
 @Service
-public class NewAction extends AbstractAction {
+public class NewAction implements Action {
 
     @Argument(name = "class", index = 0, multiValued = false, required = true, description = "The object class")
     Class clazz;
@@ -54,7 +54,7 @@ public class NewAction extends AbstractAction {
     protected DefaultConverter converter = new DefaultConverter(getClass().getClassLoader());
 
     @Override
-    protected Object doExecute() throws Exception {
+    public Object execute() throws Exception {
         if (args == null) {
             args = Collections.emptyList();
         }

http://git-wip-us.apache.org/repos/asf/karaf/blob/2e2b9324/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/PrintStackTracesAction.java
----------------------------------------------------------------------
diff --git a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/PrintStackTracesAction.java b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/PrintStackTracesAction.java
index a07850c..38ca8b5 100644
--- a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/PrintStackTracesAction.java
+++ b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/PrintStackTracesAction.java
@@ -16,11 +16,12 @@
  */
 package org.apache.karaf.shell.commands.impl;
 
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.console.AbstractAction;
-import org.apache.karaf.shell.console.SessionProperties;
-import org.apache.karaf.shell.inject.Service;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.console.Session;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
 
 /**
  * Command for showing the full tree of bundles that have been used to resolve
@@ -28,14 +29,18 @@ import org.apache.karaf.shell.inject.Service;
  */
 @Command(scope = "shell", name = "stack-traces-print", description = "Prints the full stack trace in the console when the execution of a command throws an exception.")
 @Service
-public class PrintStackTracesAction extends AbstractAction {
+public class PrintStackTracesAction implements Action {
 
     @Argument(name = "print", description="Print stack traces or not", required = false, multiValued = false)
     boolean print = true;
 
-    protected Object doExecute() throws Exception {
+    @Reference
+    Session session;
+
+    @Override
+    public Object execute() throws Exception {
         System.out.println("Printing of stacktraces set to " + print);
-        session.put(SessionProperties.PRINT_STACK_TRACES, Boolean.valueOf(print));
+        session.put(Session.PRINT_STACK_TRACES, print);
         return null;
     }
 

http://git-wip-us.apache.org/repos/asf/karaf/blob/2e2b9324/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/PrintfAction.java
----------------------------------------------------------------------
diff --git a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/PrintfAction.java b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/PrintfAction.java
index 3761a20..51b02bb 100644
--- a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/PrintfAction.java
+++ b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/PrintfAction.java
@@ -18,14 +18,14 @@ package org.apache.karaf.shell.commands.impl;
 
 import java.util.Collection;
 
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.console.AbstractAction;
-import org.apache.karaf.shell.inject.Service;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
 
 @Command(scope = "shell", name = "printf", description = "Formats and prints arguments.")
 @Service
-public class PrintfAction extends AbstractAction {
+public class PrintfAction implements Action {
 
     @Argument(index = 0, name = "format", description = "The format pattern to use", required = true, multiValued = false)
     private String format;
@@ -33,8 +33,10 @@ public class PrintfAction extends AbstractAction {
     @Argument(index = 1, name = "arguments", description = "The arguments for the given format pattern", required = true, multiValued = true)
     private Collection<Object> arguments = null;
 
-    protected Object doExecute() throws Exception {
+    @Override
+    public Object execute() throws Exception {
         System.out.printf(format, arguments.toArray());
         return null;
     }
+
 }

http://git-wip-us.apache.org/repos/asf/karaf/blob/2e2b9324/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/SleepAction.java
----------------------------------------------------------------------
diff --git a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/SleepAction.java b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/SleepAction.java
index 4f4f0e5..e8b1103 100644
--- a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/SleepAction.java
+++ b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/SleepAction.java
@@ -16,15 +16,19 @@
  */
 package org.apache.karaf.shell.commands.impl;
 
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.apache.karaf.shell.console.AbstractAction;
-import org.apache.karaf.shell.inject.Service;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 @Command(scope = "shell", name = "sleep", description = "Sleeps for a bit then wakes up.")
 @Service
-public class SleepAction extends AbstractAction {
+public class SleepAction implements Action {
+
+    private final Logger log = LoggerFactory.getLogger(getClass());
 
     @Argument(index = 0, name = "duration", description = "The amount of time to sleep. The default time unit is millisecond, use -s option to use second instead.", required = true, multiValued = false)
     private long time = -1;
@@ -32,7 +36,8 @@ public class SleepAction extends AbstractAction {
     @Option(name = "-s", aliases = { "--second" }, description = "Use a duration time in seconds instead of milliseconds.", required = false, multiValued = false)
     private boolean second = false;
 
-    protected Object doExecute() throws Exception {
+    @Override
+    public Object execute() throws Exception {
         if (second) {
             log.info("Sleeping for {} second(s)", time);
             time = time * 1000;

http://git-wip-us.apache.org/repos/asf/karaf/blob/2e2b9324/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/SortAction.java
----------------------------------------------------------------------
diff --git a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/SortAction.java b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/SortAction.java
index 6b383f7..4b9d165 100644
--- a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/SortAction.java
+++ b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/SortAction.java
@@ -34,18 +34,22 @@ import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.apache.karaf.shell.console.AbstractAction;
-import org.apache.karaf.shell.inject.Service;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Sort lines of text
  */
 @Command(scope = "shell", name = "sort", description = "Writes sorted concatenation of all files to standard output.")
 @Service
-public class SortAction extends AbstractAction {
+public class SortAction implements Action {
+
+    private final Logger log = LoggerFactory.getLogger(getClass());
 
     @Option(name = "-f", aliases = { "-ignore-case" }, description = "fold lower case to upper case characters", required = false, multiValued = false)
     private boolean caseInsensitive;
@@ -71,8 +75,8 @@ public class SortAction extends AbstractAction {
     @Argument(index = 0, name = "files", description = "A list of files separated by whitespaces", required = false, multiValued = true)
     private List<String> paths;
 
-
-    public Object doExecute() throws Exception {
+    @Override
+    public Object execute() throws Exception {
         if (paths != null && paths.size() > 0) {
             List<String> lines = new ArrayList<String>();
             for (String filename : paths) {

http://git-wip-us.apache.org/repos/asf/karaf/blob/2e2b9324/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/SourceAction.java
----------------------------------------------------------------------
diff --git a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/SourceAction.java b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/SourceAction.java
index 8eaaf18..c8bae6f 100644
--- a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/SourceAction.java
+++ b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/SourceAction.java
@@ -28,17 +28,23 @@ import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.List;
 
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.console.AbstractAction;
-import org.apache.karaf.shell.inject.Service;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.console.Session;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * TODO
  */
 @Command(scope = "shell", name = "source", description = "Run a script")
 @Service
-public class SourceAction extends AbstractAction {
+public class SourceAction implements Action {
+
+    private final Logger log = LoggerFactory.getLogger(getClass());
 
     @Argument(index = 0, name = "script", description = "A URI pointing to the script", required = true, multiValued = false)
     private String script;
@@ -46,8 +52,11 @@ public class SourceAction extends AbstractAction {
     @Argument(index = 1, name = "args", description = "Arguments for the script", required = false, multiValued = true)
     private List<Object> args;
 
+    @Reference
+    Session session;
+
     @Override
-    protected Object doExecute() throws Exception {
+    public Object execute() throws Exception {
         BufferedReader reader = null;
         Object arg0 = session.get("0");
         try {
@@ -75,7 +84,7 @@ public class SourceAction extends AbstractAction {
                 session.put( Integer.toString(i+1), args.get(i) );
             }
 
-            return session.execute(w.toString());
+            session.execute(w.toString());
         } finally {
             for (int i = 0; args != null && i < args.size(); i++) {
                 session.put( Integer.toString(i+1), null );
@@ -89,5 +98,6 @@ public class SourceAction extends AbstractAction {
                 }
             }
         }
+        return null;
     }
 }

http://git-wip-us.apache.org/repos/asf/karaf/blob/2e2b9324/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/TacAction.java
----------------------------------------------------------------------
diff --git a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/TacAction.java b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/TacAction.java
index 89fde75..5cf1b20 100644
--- a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/TacAction.java
+++ b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/TacAction.java
@@ -25,10 +25,12 @@ import java.io.FileOutputStream;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
 
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.apache.karaf.shell.console.AbstractAction;
-import org.apache.karaf.shell.inject.Service;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.console.Session;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
 
 /**
  * Grab the text from the standard input and return it as a string.
@@ -36,12 +38,16 @@ import org.apache.karaf.shell.inject.Service;
  */
 @Command(scope = "shell", name = "tac", description = "Captures the STDIN and returns it as a string. Optionally writes the content to a file.")
 @Service
-public class TacAction extends AbstractAction {
+public class TacAction implements Action {
 
     @Option(name = "-f", aliases = {}, description = "Outputs the content to the given file", required = false, multiValued = false)
     private File file;
 
-    protected Object doExecute() throws Exception {
+    @Reference
+    Session session;
+
+    @Override
+    public Object execute() throws Exception {
         StringWriter sw = new StringWriter();
         Writer[] writers;
         if (file != null) {

http://git-wip-us.apache.org/repos/asf/karaf/blob/2e2b9324/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/TailAction.java
----------------------------------------------------------------------
diff --git a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/TailAction.java b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/TailAction.java
index d9486e2..435816c 100644
--- a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/TailAction.java
+++ b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/TailAction.java
@@ -25,15 +25,19 @@ import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.LinkedList;
 
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.apache.karaf.shell.console.AbstractAction;
-import org.apache.karaf.shell.inject.Service;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 @Command(scope = "shell", name = "tail", description = "Displays the last lines of a file.")
 @Service
-public class TailAction extends AbstractAction {
+public class TailAction implements Action {
+
+    private final Logger log = LoggerFactory.getLogger(getClass());
 
     private static final int DEFAULT_NUMBER_OF_LINES = 10;
 
@@ -51,7 +55,8 @@ public class TailAction extends AbstractAction {
     @Argument(index = 0, name = "path or url", description = "A file path or url to display.", required = false, multiValued = false)
     private String path;
 
-    protected Object doExecute() throws Exception {
+    @Override
+    public Object execute() throws Exception {
         //If no paths provided assume standar input
         if (path == null || path.trim().length() == 0) {
             if (log.isDebugEnabled()) {
@@ -89,7 +94,6 @@ public class TailAction extends AbstractAction {
                 }
             }
         }
-
         return null;
     }
 

http://git-wip-us.apache.org/repos/asf/karaf/blob/2e2b9324/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/ThreadsAction.java
----------------------------------------------------------------------
diff --git a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/ThreadsAction.java b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/ThreadsAction.java
index e6c77ea..fbf6692 100644
--- a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/ThreadsAction.java
+++ b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/ThreadsAction.java
@@ -27,11 +27,11 @@ import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
 
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.apache.karaf.shell.console.AbstractAction;
-import org.apache.karaf.shell.inject.Service;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
 import org.apache.karaf.shell.table.ShellTable;
 
 /**
@@ -40,7 +40,7 @@ import org.apache.karaf.shell.table.ShellTable;
  */
 @Command(scope = "shell", name = "threads", description = "Prints the current threads (optionally with stacktraces)")
 @Service
-public class ThreadsAction extends AbstractAction {
+public class ThreadsAction implements Action {
 
     @Option(name = "--tree" , description = "Display threads as a tree")
     boolean tree = false;
@@ -70,7 +70,7 @@ public class ThreadsAction extends AbstractAction {
     boolean noFormat;
 
     @Override
-    protected Object doExecute() throws Exception {
+    public Object execute() throws Exception {
         Map<Long, ThreadInfo> threadInfos = new TreeMap<Long, ThreadInfo>();
         ThreadMXBean threadsBean = ManagementFactory.getThreadMXBean();
         ThreadInfo[] infos;
@@ -118,7 +118,6 @@ public class ThreadsAction extends AbstractAction {
             ThreadGroupData data = new ThreadGroupData(group, threadInfos);
             data.print();
         }
-
         return null;
     }
 

http://git-wip-us.apache.org/repos/asf/karaf/blob/2e2b9324/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/WatchAction.java
----------------------------------------------------------------------
diff --git a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/WatchAction.java b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/WatchAction.java
index 4ec7763..fa75134 100644
--- a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/WatchAction.java
+++ b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/WatchAction.java
@@ -24,18 +24,22 @@ import java.io.PrintStream;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
-import org.apache.felix.service.command.CommandProcessor;
-import org.apache.felix.service.command.CommandSession;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Completer;
-import org.apache.karaf.shell.commands.Option;
-import org.apache.karaf.shell.console.AbstractAction;
-import org.apache.karaf.shell.console.completer.CommandsCompleter;
-import org.apache.karaf.shell.inject.Reference;
+
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Completion;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.karaf.shell.api.console.Session;
+import org.apache.karaf.shell.api.console.SessionFactory;
+import org.apache.karaf.shell.support.ShellUtil;
+import org.apache.karaf.shell.support.completers.CommandsCompleter;
 
 @Command(scope = "shell", name = "watch", description = "Watches & refreshes the output of a command")
-public class WatchAction extends AbstractAction {
+@Service
+public class WatchAction implements Action {
 
     @Option(name = "-n", aliases = {"--interval"}, description = "The interval between executions of the command in seconds", required = false, multiValued = false)
     private long interval = 1;
@@ -44,25 +48,27 @@ public class WatchAction extends AbstractAction {
     private boolean append = false;
 
     @Argument(index = 0, name = "command", description = "The command to watch / refresh", required = true, multiValued = true)
-    @Completer(CommandsCompleter.class)
+    @Completion(CommandsCompleter.class)
     private String[] arguments;
 
     @Reference
-    CommandProcessor commandProcessor;
+    Session session;
+
+    @Reference
+    SessionFactory sessionFactory;
 
     private ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();
 
     @Override
-    protected Object doExecute() throws Exception {
+    public Object execute() throws Exception {
         if (arguments == null || arguments.length == 0) {
             System.err.println("Argument expected");
-            return null;
         } else {
             StringBuilder command = new StringBuilder();
-            for (String arg:arguments) {
+            for (String arg : arguments) {
                 command.append(arg).append(" ");
             }
-            WatchTask watchTask = new WatchTask(commandProcessor, command.toString().trim());
+            WatchTask watchTask = new WatchTask(command.toString().trim());
             executorService.scheduleAtFixedRate(watchTask, 0, interval, TimeUnit.SECONDS);
             try {
                 session.getKeyboard().read();
@@ -70,23 +76,21 @@ public class WatchAction extends AbstractAction {
             } finally {
                 executorService.shutdownNow();
                 watchTask.close();
-                return null;
             }
         }
+        return null;
     }
 
     public class WatchTask implements Runnable {
 
-        private final CommandProcessor processor;
         private final String command;
 
-        CommandSession session;
+        Session session;
         ByteArrayOutputStream byteArrayOutputStream = null;
         PrintStream printStream = null;
         boolean doDisplay = true;
 
-        public WatchTask(CommandProcessor processor, String command) {
-            this.processor = processor;
+        public WatchTask(String command) {
             this.command = command;
         }
 
@@ -94,10 +98,15 @@ public class WatchAction extends AbstractAction {
             try {
                 byteArrayOutputStream = new ByteArrayOutputStream();
                 printStream = new PrintStream(byteArrayOutputStream);
-                session = commandProcessor.createSession(null, printStream, printStream);
-                session.put("SCOPE", "shell:bundle:*");
+                session = sessionFactory.create(null, printStream, printStream);
+                session.put(Session.SCOPE, WatchAction.this.session.get(Session.SCOPE));
+                session.put(Session.SUBSHELL, WatchAction.this.session.get(Session.SUBSHELL));
                 String output = "";
-                session.execute(command);
+                try {
+                    session.execute(command);
+                } catch (Exception e) {
+                    ShellUtil.logException(session, e);
+                }
                 output = byteArrayOutputStream.toString();
                 if (doDisplay) {
                     if (!append) {
@@ -130,11 +139,4 @@ public class WatchAction extends AbstractAction {
         }
     }
 
-    public CommandProcessor getCommandProcessor() {
-        return commandProcessor;
-    }
-
-    public void setCommandProcessor(CommandProcessor commandProcessor) {
-        this.commandProcessor = commandProcessor;
-    }
 }

http://git-wip-us.apache.org/repos/asf/karaf/blob/2e2b9324/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/WcAction.java
----------------------------------------------------------------------
diff --git a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/WcAction.java b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/WcAction.java
index f87fe48..93e00bc 100644
--- a/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/WcAction.java
+++ b/shell/commands/src/main/java/org/apache/karaf/shell/commands/impl/WcAction.java
@@ -16,18 +16,18 @@
  */
 package org.apache.karaf.shell.commands.impl;
 
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.apache.karaf.shell.console.AbstractAction;
-import org.apache.karaf.shell.inject.Service;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
 
 import java.io.*;
 import java.util.List;
 
 @Command(scope = "shell", name = "wc", description = "Print newline, word, and byte counts for each file.")
 @Service
-public class WcAction extends AbstractAction {
+public class WcAction implements Action {
 
     @Option(name = "-l", aliases = { "--lines" }, description = "Print the newline counts.", required = false, multiValued = false)
     private boolean lines;
@@ -45,7 +45,7 @@ public class WcAction extends AbstractAction {
     private List<File> files;
 
     @Override
-    protected Object doExecute() throws Exception {
+    public Object execute() throws Exception {
         this.setDefaultOptions();
 
         String outputString;
@@ -58,7 +58,6 @@ public class WcAction extends AbstractAction {
         }
 
         System.out.println(outputString);
-
         return null;
     }
 

http://git-wip-us.apache.org/repos/asf/karaf/blob/2e2b9324/shell/commands/src/main/resources/META-INF/services/org/apache/karaf/shell/commands
----------------------------------------------------------------------
diff --git a/shell/commands/src/main/resources/META-INF/services/org/apache/karaf/shell/commands b/shell/commands/src/main/resources/META-INF/services/org/apache/karaf/shell/commands
index a94c585..8149c3d 100644
--- a/shell/commands/src/main/resources/META-INF/services/org/apache/karaf/shell/commands
+++ b/shell/commands/src/main/resources/META-INF/services/org/apache/karaf/shell/commands
@@ -14,24 +14,32 @@
 ##  See the License for the specific language governing permissions and
 ##  limitations under the License.
 ##---------------------------------------------------------------------------
+org.jledit.ConcreteEditorFactory
 org.apache.karaf.shell.commands.impl.AliasAction
 org.apache.karaf.shell.commands.impl.CatAction
 org.apache.karaf.shell.commands.impl.ClearAction
+org.apache.karaf.shell.commands.impl.CompletionAction
 org.apache.karaf.shell.commands.impl.DateAction
 org.apache.karaf.shell.commands.impl.EachAction
 org.apache.karaf.shell.commands.impl.EchoAction
+org.apache.karaf.shell.commands.impl.EditAction
 org.apache.karaf.shell.commands.impl.ExecuteAction
 org.apache.karaf.shell.commands.impl.GrepAction
-org.apache.karaf.shell.commands.impl.HistoryAction
 org.apache.karaf.shell.commands.impl.HeadAction
+org.apache.karaf.shell.commands.impl.HistoryAction
 org.apache.karaf.shell.commands.impl.IfAction
+org.apache.karaf.shell.commands.impl.InfoAction
 org.apache.karaf.shell.commands.impl.JavaAction
 org.apache.karaf.shell.commands.impl.LogoutAction
 org.apache.karaf.shell.commands.impl.MoreAction
 org.apache.karaf.shell.commands.impl.NewAction
 org.apache.karaf.shell.commands.impl.PrintfAction
+org.apache.karaf.shell.commands.impl.PrintStackTracesAction
 org.apache.karaf.shell.commands.impl.SleepAction
 org.apache.karaf.shell.commands.impl.SortAction
+org.apache.karaf.shell.commands.impl.SourceAction
 org.apache.karaf.shell.commands.impl.TacAction
 org.apache.karaf.shell.commands.impl.TailAction
+org.apache.karaf.shell.commands.impl.ThreadsAction
+org.apache.karaf.shell.commands.impl.WatchAction
 org.apache.karaf.shell.commands.impl.WcAction

http://git-wip-us.apache.org/repos/asf/karaf/blob/2e2b9324/shell/commands/src/main/resources/OSGI-INF/blueprint/shell-commands.xml
----------------------------------------------------------------------
diff --git a/shell/commands/src/main/resources/OSGI-INF/blueprint/shell-commands.xml b/shell/commands/src/main/resources/OSGI-INF/blueprint/shell-commands.xml
index 36c1bae..af2747c 100644
--- a/shell/commands/src/main/resources/OSGI-INF/blueprint/shell-commands.xml
+++ b/shell/commands/src/main/resources/OSGI-INF/blueprint/shell-commands.xml
@@ -19,13 +19,15 @@
 -->
 <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" default-activation="lazy">
 
+    <!--
     <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.2.0"
                     scan="org.apache.karaf.shell.commands.impl" />
 
    <bean id="commandCompleter" class="org.apache.karaf.shell.console.completer.CommandsCompleter"/>
    <service ref="commandCompleter" auto-export="all-classes"/>
+    -->
 
-   <bean class="org.osgi.util.tracker.BundleTracker" init-method="open"
+    <bean class="org.osgi.util.tracker.BundleTracker" init-method="open"
         destroy-method="close">
         <argument ref="blueprintBundleContext" />
         <argument value="32" />

http://git-wip-us.apache.org/repos/asf/karaf/blob/2e2b9324/shell/commands/src/test/java/org/apache/karaf/shell/commands/impl/GrepTest.java
----------------------------------------------------------------------
diff --git a/shell/commands/src/test/java/org/apache/karaf/shell/commands/impl/GrepTest.java b/shell/commands/src/test/java/org/apache/karaf/shell/commands/impl/GrepTest.java
index eb61a7b..3845b9d 100644
--- a/shell/commands/src/test/java/org/apache/karaf/shell/commands/impl/GrepTest.java
+++ b/shell/commands/src/test/java/org/apache/karaf/shell/commands/impl/GrepTest.java
@@ -23,8 +23,7 @@ import java.io.InputStream;
 import java.util.Arrays;
 
 import junit.framework.TestCase;
-import org.apache.karaf.shell.commands.basic.DefaultActionPreparator;
-import org.apache.karaf.shell.commands.impl.GrepAction;
+import org.apache.karaf.shell.impl.action.command.DefaultActionPreparator;
 
 public class GrepTest extends TestCase {
 
@@ -37,7 +36,7 @@ public class GrepTest extends TestCase {
             GrepAction grep = new GrepAction();
             DefaultActionPreparator preparator = new DefaultActionPreparator();
             preparator.prepare(grep, null, Arrays.<Object>asList("-C", "100", "2"));
-            grep.doExecute();
+            grep.execute();
         } finally {
             System.setIn(input);
         }

http://git-wip-us.apache.org/repos/asf/karaf/blob/2e2b9324/shell/commands/src/test/java/org/apache/karaf/shell/commands/impl/ThreadsTest.java
----------------------------------------------------------------------
diff --git a/shell/commands/src/test/java/org/apache/karaf/shell/commands/impl/ThreadsTest.java b/shell/commands/src/test/java/org/apache/karaf/shell/commands/impl/ThreadsTest.java
index 5daf61c..98d9aed 100644
--- a/shell/commands/src/test/java/org/apache/karaf/shell/commands/impl/ThreadsTest.java
+++ b/shell/commands/src/test/java/org/apache/karaf/shell/commands/impl/ThreadsTest.java
@@ -26,26 +26,26 @@ public class ThreadsTest {
     public void testThreadlist() throws Exception {
         ThreadsAction action = new ThreadsAction();
         action.list = true;
-        action.doExecute();
+        action.execute();
     }
     
     @Test
     public void testThreadInfo() throws Exception {
         ThreadsAction action = new ThreadsAction();
         action.id = 1L;
-        action.doExecute();
+        action.execute();
     }
 
     @Test
     public void testThreadTree() throws Exception {
         ThreadsAction action = new ThreadsAction();
         action.tree = true;
-        action.doExecute();
+        action.execute();
     }
 
     @Test
     public void testThreadDump() throws Exception {
         ThreadsAction action = new ThreadsAction();
-        action.doExecute();
+        action.execute();
     }
 }

http://git-wip-us.apache.org/repos/asf/karaf/blob/2e2b9324/shell/ssh/pom.xml
----------------------------------------------------------------------
diff --git a/shell/ssh/pom.xml b/shell/ssh/pom.xml
index 749e5ca..84135eb 100644
--- a/shell/ssh/pom.xml
+++ b/shell/ssh/pom.xml
@@ -40,7 +40,7 @@
     <dependencies>
         <dependency>
             <groupId>org.apache.karaf.shell</groupId>
-            <artifactId>org.apache.karaf.shell.console</artifactId>
+            <artifactId>org.apache.karaf.shell.core</artifactId>
         </dependency>
 
         <dependency>
@@ -101,22 +101,12 @@
                 <configuration>
                     <instructions>
                         <Import-Package>
-                            org.apache.aries.blueprint,
-                            org.osgi.service.blueprint.container,
-                            org.osgi.service.blueprint.reflect,
-                            org.apache.felix.service.command,
-                            org.apache.karaf.shell.commands,
-                            org.apache.karaf.shell.console,
-                            org.apache.mina.util,
-                            org.apache.sshd.server.keyprovider,
-                            org.apache.sshd.server.jaas,
-                            org.apache.sshd.server.sftp,
-                            !org.apache.sshd.server.sftp.SftpSubsystem,
                             *
                         </Import-Package>
                         <Private-Package>
                             org.apache.karaf.util
                         </Private-Package>
+                        <Bundle-Activator>org.apache.karaf.shell.ssh.Activator</Bundle-Activator>
                     </instructions>
                 </configuration>
             </plugin>

http://git-wip-us.apache.org/repos/asf/karaf/blob/2e2b9324/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/Activator.java
----------------------------------------------------------------------
diff --git a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/Activator.java b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/Activator.java
new file mode 100644
index 0000000..a61babc
--- /dev/null
+++ b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/Activator.java
@@ -0,0 +1,268 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.karaf.shell.ssh;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.apache.karaf.shell.api.action.lifecycle.Manager;
+import org.apache.karaf.shell.ssh.util.SingleServiceTracker;
+import org.apache.karaf.shell.api.console.Session;
+import org.apache.karaf.shell.api.console.SessionFactory;
+import org.apache.sshd.SshServer;
+import org.apache.sshd.common.NamedFactory;
+import org.apache.sshd.server.command.ScpCommandFactory;
+import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider;
+import org.apache.sshd.server.sftp.SftpSubsystem;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedService;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * Activate this bundle
+ */
+public class Activator implements BundleActivator, ManagedService {
+
+    ServiceRegistration registration;
+
+    List<Session> sessions = new CopyOnWriteArrayList<Session>();
+
+    BundleContext bundleContext;
+    SingleServiceTracker<SessionFactory> sessionFactoryTracker;
+    ServiceTracker<Session, Session> sessionTracker;
+    Dictionary<String, ?> configuration;
+
+    final KarafAgentFactory agentFactory = new KarafAgentFactory();
+
+    SessionFactory sessionFactory;
+    SshClientFactory sshClientFactory;
+    final Callable<SshServer> sshServerFactory = new Callable<SshServer>() {
+        @Override
+        public SshServer call() throws Exception {
+            return createSshServer(sessionFactory);
+        }
+    };
+    SshServer server;
+    final List<SshServer> servers = new ArrayList<SshServer>();
+
+
+    public void start(BundleContext context) throws Exception {
+        bundleContext = context;
+
+        Hashtable<String, Object> props = new Hashtable<String, Object>();
+        props.put(Constants.SERVICE_PID, "org.apache.karaf.shell");
+        registration = bundleContext.registerService(ManagedService.class, this, props);
+
+        sshClientFactory = new SshClientFactory(agentFactory, new File(context.getProperty("user.home"), ".sshkaraf/known_hosts"));
+
+        sessionFactoryTracker = new SingleServiceTracker<SessionFactory>(bundleContext, SessionFactory.class, new SingleServiceTracker.SingleServiceListener() {
+            @Override
+            public void serviceFound() {
+                bindSessionFactory(sessionFactoryTracker.getService());
+            }
+            @Override
+            public void serviceLost() {
+                unbindSessionFactory();
+            }
+            @Override
+            public void serviceReplaced() {
+                serviceLost();
+                serviceFound();
+            }
+        });
+        sessionFactoryTracker.open();
+
+        sessionTracker = new ServiceTracker<Session, Session>(bundleContext, Session.class, null) {
+            @Override
+            public Session addingService(ServiceReference<Session> reference) {
+                Session session = super.addingService(reference);
+                agentFactory.registerSession(session);
+                return session;
+            }
+            @Override
+            public void removedService(ServiceReference<Session> reference, Session session) {
+                agentFactory.unregisterSession(session);
+                super.removedService(reference, session);
+            }
+        };
+        sessionTracker.open();
+
+    }
+
+    private void bindSessionFactory(final SessionFactory sessionFactory) {
+        this.sessionFactory = sessionFactory;
+        this.sessionFactory.getRegistry().register(sshServerFactory, SshServer.class);
+        this.sessionFactory.getRegistry().register(sshClientFactory);
+        this.sessionFactory.getRegistry().getService(Manager.class).register(SshServerAction.class);
+        this.sessionFactory.getRegistry().getService(Manager.class).register(SshAction.class);
+        if (Boolean.parseBoolean(Activator.this.bundleContext.getProperty("karaf.startRemoteShell"))) {
+            server = createSshServer(sessionFactory);
+            try {
+                server.start();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    private void unbindSessionFactory() {
+        this.sessionFactory.getRegistry().getService(Manager.class).unregister(SshAction.class);
+        this.sessionFactory.getRegistry().getService(Manager.class).unregister(SshServerAction.class);
+        this.sessionFactory.getRegistry().unregister(sshClientFactory);
+        this.sessionFactory.getRegistry().unregister(sshServerFactory);
+        SshServer srv = server;
+        server = null;
+        if (srv != null) {
+            try {
+                srv.stop();
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    public void stop(BundleContext context) {
+        registration.unregister();
+        sessionTracker.close();
+        sessionFactoryTracker.close();
+        synchronized (servers) {
+            for (SshServer server : servers) {
+                try {
+                    server.stop();
+                } catch (InterruptedException e) {
+                    // TODO: log exception
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+
+    @Override
+    public void updated(Dictionary<String, ?> configuration) throws ConfigurationException {
+        this.configuration = configuration;
+    }
+
+    private int getInt(String key, int def) {
+        Dictionary<String, ?> config = this.configuration;
+        if (config != null) {
+            Object val = config.get(key);
+            if (val instanceof Number) {
+                return ((Number) val).intValue();
+            } else if (val != null) {
+                return Integer.parseInt(val.toString());
+            }
+        }
+        return def;
+    }
+
+    private long getLong(String key, long def) {
+        Dictionary<String, ?> config = this.configuration;
+        if (config != null) {
+            Object val = config.get(key);
+            if (val instanceof Number) {
+                return ((Number) val).longValue();
+            } else if (val != null) {
+                return Long.parseLong(val.toString());
+            }
+        }
+        return def;
+    }
+
+    private String getString(String key, String def) {
+        Dictionary<String, ?> config = this.configuration;
+        if (config != null) {
+            Object val = config.get(key);
+            if (val != null) {
+                return val.toString();
+            }
+        }
+        return def;
+    }
+
+    protected SshServer createSshServer(SessionFactory sessionFactory) {
+        int sshPort           = getInt("sshPort", 8181);
+        String sshHost        = getString("sshHost", "0.0.0.0");
+        long sshIdleTimeout   = getLong("sshIdleTimeout", 1800000);
+        String sshRealm       = getString("sshRealm", "karaf");
+        String hostKey        = getString("hostKey", System.getProperty("karaf.base") + "/etc/host.key");
+        String authMethods    = getString("authMethods", "keyboard-interactive,password,publickey");
+        int keySize           = getInt("keySize", 1024);
+        String algorithm      = getString("algorithm", "DSA");
+        String macs           = getString("macs", "hmac-sha1");
+        String ciphers        = getString("ciphers", "aes256-ctr,aes192-ctr,aes128-ctr,arcfour256");
+
+        SimpleGeneratorHostKeyProvider keyPairProvider = new SimpleGeneratorHostKeyProvider();
+        keyPairProvider.setPath(hostKey);
+        keyPairProvider.setKeySize(keySize);
+        keyPairProvider.setAlgorithm(algorithm);
+
+        KarafJaasAuthenticator authenticator = new KarafJaasAuthenticator(sshRealm);
+
+        UserAuthFactoriesFactory authFactoriesFactory = new UserAuthFactoriesFactory();
+        authFactoriesFactory.setAuthMethods(authMethods);
+
+        SshServer server = SshServer.setUpDefaultServer();
+        server.setPort(sshPort);
+        server.setHost(sshHost);
+        server.setMacFactories(SshUtils.buildMacs(macs));
+        server.setCipherFactories(SshUtils.buildCiphers(ciphers));
+        server.setShellFactory(new ShellFactoryImpl(sessionFactory));
+        server.setCommandFactory(new ScpCommandFactory(new ShellCommandFactory(sessionFactory)));
+        server.setSubsystemFactories(Arrays.<NamedFactory<org.apache.sshd.server.Command>>asList(new SftpSubsystem.Factory()));
+        server.setKeyPairProvider(keyPairProvider);
+        server.setPasswordAuthenticator(authenticator);
+        server.setPublickeyAuthenticator(authenticator);
+        server.setFileSystemFactory(new KarafFileSystemFactory());
+        server.setUserAuthFactories(authFactoriesFactory.getFactories());
+        server.setAgentFactory(agentFactory);
+        server.getProperties().put(SshServer.IDLE_TIMEOUT, Long.toString(sshIdleTimeout));
+
+        synchronized (servers) {
+            servers.add(server);
+        }
+        return server;
+    }
+
+    public void bindCommandSession(Session session) {
+        sessions.add(session);
+        if (agentFactory != null) {
+            agentFactory.registerSession(session);
+        }
+    }
+
+    public void unbindCommandSession(Session session) {
+        sessions.remove(session);
+        if (agentFactory != null) {
+            agentFactory.unregisterSession(session);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/2e2b9324/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ActivatorNoOsgi.java
----------------------------------------------------------------------
diff --git a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ActivatorNoOsgi.java b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ActivatorNoOsgi.java
new file mode 100644
index 0000000..f71c5ef
--- /dev/null
+++ b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ActivatorNoOsgi.java
@@ -0,0 +1,33 @@
+package org.apache.karaf.shell.ssh;
+
+import java.io.File;
+
+import org.apache.karaf.shell.api.action.lifecycle.Destroy;
+import org.apache.karaf.shell.api.action.lifecycle.Init;
+import org.apache.karaf.shell.api.action.lifecycle.Manager;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.console.SessionFactory;
+
+public class ActivatorNoOsgi {
+
+    @Reference
+    SessionFactory sessionFactory;
+
+    KarafAgentFactory agentFactory;
+    SshClientFactory sshClientFactory;
+
+    @Init
+    public void init() {
+        agentFactory = new KarafAgentFactory();
+        sshClientFactory = new SshClientFactory(agentFactory, new File(System.getProperty("user.home"), ".sshkaraf/known_hosts"));
+        sessionFactory.getRegistry().register(sshClientFactory);
+        sessionFactory.getRegistry().getService(Manager.class).register(SshAction.class);
+    }
+
+    @Destroy
+    public void destroy() {
+        sessionFactory.getRegistry().register(sshClientFactory);
+        sessionFactory.getRegistry().getService(Manager.class).register(SshAction.class);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/karaf/blob/2e2b9324/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafAgentFactory.java
----------------------------------------------------------------------
diff --git a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafAgentFactory.java b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafAgentFactory.java
index 45d1f36..da4d43a 100644
--- a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafAgentFactory.java
+++ b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafAgentFactory.java
@@ -26,7 +26,6 @@ import java.security.KeyPair;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
-import org.apache.felix.service.command.CommandSession;
 import org.apache.sshd.agent.SshAgent;
 import org.apache.sshd.agent.SshAgentFactory;
 import org.apache.sshd.agent.SshAgentServer;
@@ -38,7 +37,6 @@ import org.apache.sshd.common.Channel;
 import org.apache.sshd.common.NamedFactory;
 import org.apache.sshd.common.Session;
 import org.apache.sshd.server.session.ServerSession;
-import org.osgi.framework.BundleContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -49,16 +47,6 @@ public class KarafAgentFactory implements SshAgentFactory {
     private final Map<String, AgentServerProxy> proxies = new ConcurrentHashMap<String, AgentServerProxy>();
     private final Map<String, SshAgent> locals = new ConcurrentHashMap<String, SshAgent>();
 
-    private BundleContext bundleContext;
-
-    public BundleContext getBundleContext() {
-        return bundleContext;
-    }
-
-    public void setBundleContext(BundleContext bundleContext) {
-        this.bundleContext = bundleContext;
-    }
-
     public NamedFactory<Channel> getChannelForwardingFactory() {
         return new ChannelAgentForwarding.Factory();
     }
@@ -97,11 +85,11 @@ public class KarafAgentFactory implements SshAgentFactory {
         };
     }
 
-    public void registerCommandSession(CommandSession session) {
+    public void registerSession(org.apache.karaf.shell.api.console.Session session) {
         try {
             String user = (String) session.get("USER");
             SshAgent agent = new AgentImpl();
-            URL url = bundleContext.getBundle().getResource("karaf.key");
+            URL url = getClass().getClassLoader().getResource("karaf.key");
             InputStream is = url.openStream();
             ObjectInputStream r = new ObjectInputStream(is);
             KeyPair keyPair = (KeyPair) r.readObject();
@@ -114,7 +102,7 @@ public class KarafAgentFactory implements SshAgentFactory {
         }
     }
 
-    public void unregisterCommandSession(CommandSession session) {
+    public void unregisterSession(org.apache.karaf.shell.api.console.Session session) {
         try {
             if (session != null && session.get(SshAgent.SSH_AUTHSOCKET_ENV_NAME) != null) {
                 String agentId = (String) session.get(SshAgent.SSH_AUTHSOCKET_ENV_NAME);

http://git-wip-us.apache.org/repos/asf/karaf/blob/2e2b9324/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafJaasAuthenticator.java
----------------------------------------------------------------------
diff --git a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafJaasAuthenticator.java b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafJaasAuthenticator.java
index 0562bb2..6df591a 100644
--- a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafJaasAuthenticator.java
+++ b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/KarafJaasAuthenticator.java
@@ -47,6 +47,13 @@ public class KarafJaasAuthenticator implements PasswordAuthenticator, PublickeyA
 
     private String realm;
 
+    public KarafJaasAuthenticator() {
+    }
+
+    public KarafJaasAuthenticator(String realm) {
+        this.realm = realm;
+    }
+
     public String getRealm() {
         return realm;
     }

http://git-wip-us.apache.org/repos/asf/karaf/blob/2e2b9324/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellCommand.java
----------------------------------------------------------------------
diff --git a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellCommand.java b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellCommand.java
index a825f07..62d8ba6 100644
--- a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellCommand.java
+++ b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellCommand.java
@@ -25,12 +25,11 @@ import java.util.Map;
 
 import javax.security.auth.Subject;
 
-import org.apache.felix.service.command.CommandProcessor;
-import org.apache.felix.service.command.CommandSession;
-import org.apache.felix.service.command.Converter;
 import org.apache.karaf.jaas.modules.JaasHelper;
-import org.apache.karaf.shell.util.ShellUtil;
 import org.apache.karaf.util.StreamUtils;
+import org.apache.karaf.shell.api.console.Session;
+import org.apache.karaf.shell.api.console.SessionFactory;
+import org.apache.karaf.shell.support.ShellUtil;
 import org.apache.sshd.server.Command;
 import org.apache.sshd.server.Environment;
 import org.apache.sshd.server.ExitCallback;
@@ -57,10 +56,10 @@ public class ShellCommand implements Command, SessionAware {
     private OutputStream err;
     private ExitCallback callback;
     private ServerSession session;
-    private CommandProcessor commandProcessor;
+    private SessionFactory sessionFactory;
 
-    public ShellCommand(CommandProcessor commandProcessor, String command) {
-        this.commandProcessor = commandProcessor;
+    public ShellCommand(SessionFactory sessionFactory, String command) {
+        this.sessionFactory = sessionFactory;
         this.command = command;
     }
 
@@ -86,9 +85,7 @@ public class ShellCommand implements Command, SessionAware {
 
     public void start(final Environment env) throws IOException {
         try {
-            final CommandSession session = commandProcessor.createSession(in, new PrintStream(out), new PrintStream(err));
-            session.put("SCOPE", "shell:osgi:*");
-            session.put("APPLICATION", System.getProperty("karaf.name", "root"));
+            final Session session = sessionFactory.create(in, new PrintStream(out), new PrintStream(err));
             for (Map.Entry<String,String> e : env.getEnv().entrySet()) {
                 session.put(e.getKey(), e.getValue());
             }
@@ -114,7 +111,8 @@ public class ShellCommand implements Command, SessionAware {
                 }
                 if (result != null)
                 {
-                    session.getConsole().println(session.format(result, Converter.INSPECT));
+                    // TODO: print the result of the command ?
+//                    session.getConsole().println(session.format(result, Converter.INSPECT));
                 }
             } catch (Throwable t) {
                 ShellUtil.logException(session, t);
@@ -130,7 +128,7 @@ public class ShellCommand implements Command, SessionAware {
     public void destroy() {
 	}
 
-    private void executeScript(String scriptFileName, CommandSession session) {
+    private void executeScript(String scriptFileName, Session session) {
         if (scriptFileName != null) {
             Reader r = null;
             try {

http://git-wip-us.apache.org/repos/asf/karaf/blob/2e2b9324/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellCommandFactory.java
----------------------------------------------------------------------
diff --git a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellCommandFactory.java b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellCommandFactory.java
index a1de13d..dc1f04e 100644
--- a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellCommandFactory.java
+++ b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellCommandFactory.java
@@ -18,20 +18,20 @@
  */
 package org.apache.karaf.shell.ssh;
 
-import org.apache.felix.service.command.CommandProcessor;
+import org.apache.karaf.shell.api.console.SessionFactory;
 import org.apache.sshd.server.Command;
 import org.apache.sshd.server.CommandFactory;
 
 public class ShellCommandFactory implements CommandFactory {
 
-    private CommandProcessor commandProcessor;
+    private SessionFactory sessionFactory;
 
-    public void setCommandProcessor(CommandProcessor commandProcessor) {
-        this.commandProcessor = commandProcessor;
+    public ShellCommandFactory(SessionFactory sessionFactory) {
+        this.sessionFactory = sessionFactory;
     }
 
     public Command createCommand(String command) {
-        return new ShellCommand(commandProcessor, command);
+        return new ShellCommand(sessionFactory, command);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/karaf/blob/2e2b9324/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellFactoryImpl.java
----------------------------------------------------------------------
diff --git a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellFactoryImpl.java b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellFactoryImpl.java
index 657193b..a6defed 100644
--- a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellFactoryImpl.java
+++ b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/ShellFactoryImpl.java
@@ -29,30 +29,27 @@ import java.util.Map;
 
 import javax.security.auth.Subject;
 
-import jline.Terminal;
-
-import org.apache.felix.service.command.CommandSession;
 import org.apache.karaf.jaas.modules.JaasHelper;
-import org.apache.karaf.shell.console.Console;
-import org.apache.karaf.shell.console.factory.ConsoleFactory;
-import org.apache.karaf.shell.util.ShellUtil;
+import org.apache.karaf.shell.api.console.Session;
+import org.apache.karaf.shell.api.console.SessionFactory;
+import org.apache.karaf.shell.api.console.Terminal;
+import org.apache.karaf.shell.support.ShellUtil;
 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.apache.sshd.server.SessionAware;
 import org.apache.sshd.server.session.ServerSession;
-import org.osgi.service.blueprint.container.ReifiedType;
 
 /**
  * SSHD {@link org.apache.sshd.server.Command} factory which provides access to
  * Shell.
  */
 public class ShellFactoryImpl implements Factory<Command> {
-    private ConsoleFactory consoleFactory;
+    private SessionFactory sessionFactory;
 
-    public ShellFactoryImpl(ConsoleFactory consoleFactory) {
-        this.consoleFactory = consoleFactory;
+    public ShellFactoryImpl(SessionFactory sessionFactory) {
+        this.sessionFactory = sessionFactory;
     }
 
     public Command create() {
@@ -106,15 +103,14 @@ public class ShellFactoryImpl implements Factory<Command> {
                 if (encoding != null && encoding.indexOf('.') > 0) {
                     encoding = encoding.substring(encoding.indexOf('.') + 1);
                 }
-                final Console console = consoleFactory.create(in,
+                final Session session = sessionFactory.create(in,
                         lfToCrLfPrintStream(out), lfToCrLfPrintStream(err), terminal, encoding, destroyCallback);
-                final CommandSession session = console.getSession();
                 for (Map.Entry<String, String> e : env.getEnv().entrySet()) {
                     session.put(e.getKey(), e.getValue());
                 }
                 JaasHelper.doAs(subject, new PrivilegedAction<Object>() {
                     public Object run() {
-                        new Thread(console, "Karaf ssh console user " + ShellUtil.getCurrentUserName()).start();
+                        new Thread(session, "Karaf ssh console user " + ShellUtil.getCurrentUserName()).start();
                         return null;
                     }
                 });
@@ -158,23 +154,6 @@ public class ShellFactoryImpl implements Factory<Command> {
         }
     }
 
-    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;
-        }
-    }
-
     // TODO: remove this class when sshd use lf->crlf conversion by default
     public class LfToCrLfFilterOutputStream extends FilterOutputStream {
 

http://git-wip-us.apache.org/repos/asf/karaf/blob/2e2b9324/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshAction.java
----------------------------------------------------------------------
diff --git a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshAction.java b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshAction.java
index ed59460..0f2ae21 100644
--- a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshAction.java
+++ b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshAction.java
@@ -22,14 +22,14 @@ import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.util.List;
 
-import jline.Terminal;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import jline.console.ConsoleReader;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.apache.karaf.shell.console.SessionProperties;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.karaf.shell.api.console.Session;
+import org.apache.karaf.shell.api.console.Terminal;
 import org.apache.sshd.ClientChannel;
 import org.apache.sshd.ClientSession;
 import org.apache.sshd.SshClient;
@@ -42,7 +42,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 @Command(scope = "ssh", name = "ssh", description = "Connects to a remote SSH server")
-public class SshAction extends OsgiCommandSupport {
+@Service
+public class SshAction implements Action {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
     @Option(name="-l", aliases={"--username"}, description = "The user name for remote login", required = false, multiValued = false)
@@ -63,9 +64,11 @@ public class SshAction extends OsgiCommandSupport {
     @Argument(index = 1, name = "command", description = "Optional command to execute", required = false, multiValued = true)
     private List<String> command;
 
-	private ClientSession sshSession;
+    @Reference
+    private Session session;
 
-	private SshClientFactory sshClientFactory;
+    @Reference
+    private SshClientFactory sshClientFactory;
 
     private final static String keyChangedMessage =
             " @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ \n" +
@@ -85,7 +88,7 @@ public class SshAction extends OsgiCommandSupport {
 	}
 
 	@Override
-    protected Object doExecute() throws Exception {
+    public Object execute() throws Exception {
 
         if (hostname.indexOf('@') >= 0) {
             if (username == null) {
@@ -104,7 +107,7 @@ public class SshAction extends OsgiCommandSupport {
         if (username == null) {
             log.debug("Prompting user for login");
             if (username == null) {
-                username = readLine("Login: ");
+                username = session.readLine("Login: ", null);
             }
         }
 
@@ -121,9 +124,9 @@ public class SshAction extends OsgiCommandSupport {
         try {
             ConnectFuture future = client.connect(hostname, port);
             future.await();
-            sshSession = future.getSession();
+            ClientSession sshSession = future.getSession();
 
-            Object oldIgnoreInterrupts = this.session.get(SessionProperties.IGNORE_INTERRUPTS);
+            Object oldIgnoreInterrupts = this.session.get(Session.IGNORE_INTERRUPTS);
 
             try {
 
@@ -145,7 +148,7 @@ public class SshAction extends OsgiCommandSupport {
                 if (!authed) {
                     if (password == null) {
                         log.debug("Prompting user for password");
-                        password = readLine("Password: ");
+                        password = session.readLine("Password: ", '*');
                     } else {
                         log.debug("Password provided using command line option");
                     }
@@ -167,7 +170,7 @@ public class SshAction extends OsgiCommandSupport {
                 }
 
                 System.out.println("Connected");
-                this.session.put( SessionProperties.IGNORE_INTERRUPTS, Boolean.TRUE );
+                this.session.put( Session.IGNORE_INTERRUPTS, Boolean.TRUE );
 
                 StringBuilder sb = new StringBuilder();
                 if (command != null) {
@@ -199,7 +202,7 @@ public class SshAction extends OsgiCommandSupport {
                 channel.open();
                 channel.waitFor(ClientChannel.CLOSED, 0);
             } finally {
-                session.put( SessionProperties.IGNORE_INTERRUPTS, oldIgnoreInterrupts );
+                session.put( Session.IGNORE_INTERRUPTS, oldIgnoreInterrupts );
                 sshSession.close(false);
             }
         } finally {
@@ -210,17 +213,8 @@ public class SshAction extends OsgiCommandSupport {
     }
 
     private int getTermWidth() {
-        Terminal term = (Terminal) session.get(".jline.terminal");
+        Terminal term = session.getTerminal();
         return term != null ? term.getWidth() : 80;
     }
 
-    public String readLine(String msg) throws IOException {
-        return readLine(msg, null);
-    }
-
-    public String readLine(String msg, Character mask) throws IOException {
-        ConsoleReader reader = (ConsoleReader) session.get(".jline.reader");
-        return reader.readLine(msg, mask);
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/karaf/blob/2e2b9324/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerAction.java
----------------------------------------------------------------------
diff --git a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerAction.java b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerAction.java
index e92db70..6b45a0a 100644
--- a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerAction.java
+++ b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerAction.java
@@ -18,17 +18,18 @@
  */
 package org.apache.karaf.shell.ssh;
 
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
 import org.apache.sshd.SshServer;
-import org.apache.karaf.shell.console.BlueprintContainerAware;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.osgi.service.blueprint.container.BlueprintContainer;
 
 @Command(scope = "ssh", name = "sshd", description = "Creates a SSH server")
-public class SshServerAction extends OsgiCommandSupport implements BlueprintContainerAware
+@Service
+public class SshServerAction implements Action
 {
     private final Logger log = LoggerFactory.getLogger(getClass());
 
@@ -41,29 +42,21 @@ public class SshServerAction extends OsgiCommandSupport implements BlueprintCont
     @Option(name = "-i", aliases = { "--idle-timeout" }, description = "The session idle timeout (Default: 1800000ms)", required = false, multiValued = false)
     private long idleTimeout = 1800000;
 
-    private BlueprintContainer container;
+    @Reference
+    private SshServer server;
 
-    private String sshServerId;
-
-    public void setBlueprintContainer(final BlueprintContainer container) {
-        assert container != null;
-        this.container = container;
-    }
-
-    public void setSshServerId(String sshServerId) {
-        this.sshServerId = sshServerId;
+    public void setServer(SshServer server) {
+        this.server = server;
     }
 
-    protected Object doExecute() throws Exception {
-        SshServer server = (SshServer) container.getComponentInstance(sshServerId);
-
+    public Object execute() throws Exception {
         log.debug("Created server: {}", server);
 
         // port number
         server.setPort(port);
 
         // idle timeout
-        server.getProperties().put(SshServer.IDLE_TIMEOUT, new Long(idleTimeout).toString());
+        server.getProperties().put(SshServer.IDLE_TIMEOUT, Long.toString(idleTimeout));
 
         // starting the SSHd server
         server.start();

http://git-wip-us.apache.org/repos/asf/karaf/blob/2e2b9324/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerFactory.java
----------------------------------------------------------------------
diff --git a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerFactory.java b/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerFactory.java
deleted file mode 100644
index 4789669..0000000
--- a/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerFactory.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.karaf.shell.ssh;
-
-import org.apache.sshd.SshServer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class SshServerFactory {
-
-    private static final Logger LOGGER = LoggerFactory.getLogger(SshServerFactory.class);
-
-    private long idleTimeout;
-    private boolean start;
-
-    private SshServer server;
-
-    public SshServerFactory(SshServer server) {
-        this.server = server;
-    }
-
-    public boolean isStart() {
-        return start;
-    }
-
-    public void setStart(boolean start) {
-        this.start = start;
-    }
-
-    public long getIdleTimeout() {
-        return idleTimeout;
-    }
-
-    public void setIdleTimeout(long idleTimeout) {
-        this.idleTimeout = idleTimeout;
-    }
-
-    public void start() {
-        if (start) {
-            try {
-                server.getProperties().put(SshServer.IDLE_TIMEOUT, new Long(idleTimeout).toString());
-                server.start();
-            } catch (Exception e) {
-                LOGGER.info("Error updating SSH server", e);
-            }
-        }
-    }
-
-    public void stop() {
-        if (start && server != null) {
-            try {
-                server.stop();
-            } catch (Exception e) {
-                LOGGER.info("Error stopping SSH server", e);
-            } finally {
-                server = null;
-            }
-        }
-    }
-
-}