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/02/20 10:28:54 UTC

[2/2] git commit: Fix SimpleCommand

Fix SimpleCommand

Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/8fd6385a
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/8fd6385a
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/8fd6385a

Branch: refs/heads/master
Commit: 8fd6385a61aa707799955100d2a46e9b0acdbd01
Parents: 10d8447
Author: Guillaume Nodet <gn...@gmail.com>
Authored: Thu Feb 20 10:24:34 2014 +0100
Committer: Guillaume Nodet <gn...@gmail.com>
Committed: Thu Feb 20 10:24:34 2014 +0100

----------------------------------------------------------------------
 .../karaf/shell/commands/basic/SimpleCommand.java       | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/8fd6385a/shell/console/src/main/java/org/apache/karaf/shell/commands/basic/SimpleCommand.java
----------------------------------------------------------------------
diff --git a/shell/console/src/main/java/org/apache/karaf/shell/commands/basic/SimpleCommand.java b/shell/console/src/main/java/org/apache/karaf/shell/commands/basic/SimpleCommand.java
index 6999236..4ea5dfc 100644
--- a/shell/console/src/main/java/org/apache/karaf/shell/commands/basic/SimpleCommand.java
+++ b/shell/console/src/main/java/org/apache/karaf/shell/commands/basic/SimpleCommand.java
@@ -23,6 +23,7 @@ import java.util.Hashtable;
 import org.apache.felix.service.command.Function;
 import org.apache.karaf.shell.commands.Action;
 import org.apache.karaf.shell.commands.Command;
+import org.apache.karaf.shell.commands.CommandWithAction;
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.framework.BundleContext;
 
@@ -62,8 +63,7 @@ public class SimpleCommand extends AbstractCommand {
         }
     }
 
-
-    public static ServiceRegistration<Function> export(BundleContext context, Class<? extends Action> actionClass)
+    public static ServiceRegistration export(BundleContext context, Class<? extends Action> actionClass)
     {
         Command cmd = actionClass.getAnnotation(Command.class);
         if (cmd == null)
@@ -71,10 +71,12 @@ public class SimpleCommand extends AbstractCommand {
             throw new IllegalArgumentException("Action class is not annotated with @Command");
         }
         Hashtable<String, String> props = new Hashtable<String, String>();
-        props.put("bundles.command.scope", cmd.scope());
-        props.put("bundles.command.function", cmd.name());
+        props.put("osgi.command.scope", cmd.scope());
+        props.put("osgi.command.function", cmd.name());
         SimpleCommand command = new SimpleCommand(actionClass);
-        return context.registerService(Function.class, command, props);
+        return context.registerService(
+                new String[] { Function.class.getName(), CommandWithAction.class.getName() },
+                command, props);
     }
 
 }