karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject [01/13] git commit: [KARAF-2805] Refactor Registry#hasCommand to Registry#getCommand
Date Mon, 07 Apr 2014 08:52:52 GMT
Repository: karaf
Updated Branches:
  refs/heads/master fe2627f22 -> 38502e415


[KARAF-2805] Refactor Registry#hasCommand to Registry#getCommand


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

Branch: refs/heads/master
Commit: 5337778a3e2df088d77157fe876f14103fc9710c
Parents: fe2627f
Author: Guillaume Nodet <gnodet@gmail.com>
Authored: Thu Apr 3 09:43:01 2014 +0200
Committer: Guillaume Nodet <gnodet@gmail.com>
Committed: Mon Apr 7 10:52:23 2014 +0200

----------------------------------------------------------------------
 .../org/apache/karaf/itests/KarafTestSupport.java     |  2 +-
 .../org/apache/karaf/shell/api/console/Registry.java  |  3 +--
 .../impl/action/osgi/AggregateServiceTracker.java     |  2 +-
 .../shell/impl/action/osgi/CommandExtension.java      |  2 +-
 .../karaf/shell/impl/action/osgi/RegistryImpl.java    | 14 ++++++++++----
 .../apache/karaf/shell/impl/console/RegistryImpl.java | 14 ++++++++++----
 6 files changed, 24 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/5337778a/itests/src/test/java/org/apache/karaf/itests/KarafTestSupport.java
----------------------------------------------------------------------
diff --git a/itests/src/test/java/org/apache/karaf/itests/KarafTestSupport.java b/itests/src/test/java/org/apache/karaf/itests/KarafTestSupport.java
index ea7ac9c..5062c64 100644
--- a/itests/src/test/java/org/apache/karaf/itests/KarafTestSupport.java
+++ b/itests/src/test/java/org/apache/karaf/itests/KarafTestSupport.java
@@ -291,7 +291,7 @@ public class KarafTestSupport {
             long start = System.currentTimeMillis();
             long cur   = start;
             while (cur - start < SERVICE_TIMEOUT) {
-                if (sessionFactory.getRegistry().hasCommand(scope, name)) {
+                if (sessionFactory.getRegistry().getCommand(scope, name) != null) {
                     return;
                 }
                 Thread.sleep(100);

http://git-wip-us.apache.org/repos/asf/karaf/blob/5337778a/shell/core/src/main/java/org/apache/karaf/shell/api/console/Registry.java
----------------------------------------------------------------------
diff --git a/shell/core/src/main/java/org/apache/karaf/shell/api/console/Registry.java b/shell/core/src/main/java/org/apache/karaf/shell/api/console/Registry.java
index 35c7c75..8df1b22 100644
--- a/shell/core/src/main/java/org/apache/karaf/shell/api/console/Registry.java
+++ b/shell/core/src/main/java/org/apache/karaf/shell/api/console/Registry.java
@@ -40,9 +40,8 @@ public interface Registry {
      * @param scope
      * @param name
      * @return
-     * @throws InterruptedException
      */
-    boolean hasCommand(String scope, String name);
+    Command getCommand(String scope, String name);
 
     /**
      * Register a delayed service (or factory).

http://git-wip-us.apache.org/repos/asf/karaf/blob/5337778a/shell/core/src/main/java/org/apache/karaf/shell/impl/action/osgi/AggregateServiceTracker.java
----------------------------------------------------------------------
diff --git a/shell/core/src/main/java/org/apache/karaf/shell/impl/action/osgi/AggregateServiceTracker.java
b/shell/core/src/main/java/org/apache/karaf/shell/impl/action/osgi/AggregateServiceTracker.java
index dad5ab2..8f45115 100644
--- a/shell/core/src/main/java/org/apache/karaf/shell/impl/action/osgi/AggregateServiceTracker.java
+++ b/shell/core/src/main/java/org/apache/karaf/shell/impl/action/osgi/AggregateServiceTracker.java
@@ -144,7 +144,7 @@ public abstract class AggregateServiceTracker {
         public List<String> getMissingServices() {
             List<String> missing = new ArrayList<String>();
             for (SingleServiceTracker tracker : singleTrackers.values()) {
-                if (single.containsKey(tracker.getTrackedClass())) {
+                if (!single.containsKey(tracker.getTrackedClass())) {
                     missing.add(tracker.getTrackedClass().getName());
                 }
             }

http://git-wip-us.apache.org/repos/asf/karaf/blob/5337778a/shell/core/src/main/java/org/apache/karaf/shell/impl/action/osgi/CommandExtension.java
----------------------------------------------------------------------
diff --git a/shell/core/src/main/java/org/apache/karaf/shell/impl/action/osgi/CommandExtension.java
b/shell/core/src/main/java/org/apache/karaf/shell/impl/action/osgi/CommandExtension.java
index 80f9d21..a2cf8a4 100644
--- a/shell/core/src/main/java/org/apache/karaf/shell/impl/action/osgi/CommandExtension.java
+++ b/shell/core/src/main/java/org/apache/karaf/shell/impl/action/osgi/CommandExtension.java
@@ -132,7 +132,7 @@ public class CommandExtension implements Extension {
         } else if (isSatisfied) {
             action = "Registering";
         } else {
-            action = null;
+            return;
         }
         LOGGER.info("{} commands for bundle {}/{}",
                 action,

http://git-wip-us.apache.org/repos/asf/karaf/blob/5337778a/shell/core/src/main/java/org/apache/karaf/shell/impl/action/osgi/RegistryImpl.java
----------------------------------------------------------------------
diff --git a/shell/core/src/main/java/org/apache/karaf/shell/impl/action/osgi/RegistryImpl.java
b/shell/core/src/main/java/org/apache/karaf/shell/impl/action/osgi/RegistryImpl.java
index e1cdd67..ad1a1e5 100644
--- a/shell/core/src/main/java/org/apache/karaf/shell/impl/action/osgi/RegistryImpl.java
+++ b/shell/core/src/main/java/org/apache/karaf/shell/impl/action/osgi/RegistryImpl.java
@@ -44,14 +44,20 @@ public class RegistryImpl implements Registry {
     }
 
     @Override
-    public boolean hasCommand(String scope, String name) {
-        if (parent != null && parent.hasCommand(scope, name)) {
-            return true;
+    public Command getCommand(String scope, String name) {
+        if (parent != null) {
+            Command command = parent.getCommand(scope, name);
+            if (command != null) {
+                return command;
+            }
         }
         synchronized (services) {
             List<Command> cmds = commands.get(scope + ":" + name);
-            return cmds != null && !cmds.isEmpty();
+            if (cmds != null && !cmds.isEmpty()) {
+                return cmds.get(0);
+            }
         }
+        return null;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/karaf/blob/5337778a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/RegistryImpl.java
----------------------------------------------------------------------
diff --git a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/RegistryImpl.java
b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/RegistryImpl.java
index 99113b7..0d39a95 100644
--- a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/RegistryImpl.java
+++ b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/RegistryImpl.java
@@ -44,14 +44,20 @@ public class RegistryImpl implements Registry {
     }
 
     @Override
-    public boolean hasCommand(String scope, String name) {
-        if (parent != null && parent.hasCommand(scope, name)) {
-            return true;
+    public Command getCommand(String scope, String name) {
+        if (parent != null) {
+            Command command = parent.getCommand(scope, name);
+            if (command != null) {
+                return command;
+            }
         }
         synchronized (services) {
             List<Command> cmds = commands.get(scope + ":" + name);
-            return cmds != null && !cmds.isEmpty();
+            if (cmds != null && !cmds.isEmpty()) {
+                return cmds.get(0);
+            }
         }
+        return null;
     }
 
     @Override


Mime
View raw message