Repository: karaf
Updated Branches:
  refs/heads/karaf-3.0.x 409700101 -> 167e797ef


[KARAF-3041] Provide additional helper methods in OsgiCommandSupport


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

Branch: refs/heads/karaf-3.0.x
Commit: 167e797efc7513501c50609f6465689f02fb552d
Parents: 4097001
Author: Guillaume Nodet <gno...@gmail.com>
Authored: Thu Jun 12 23:26:57 2014 +0200
Committer: Guillaume Nodet <gno...@gmail.com>
Committed: Thu Jun 12 23:34:25 2014 +0200

----------------------------------------------------------------------
 .../karaf/shell/console/OsgiCommandSupport.java    | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/167e797e/shell/console/src/main/java/org/apache/karaf/shell/console/OsgiCommandSupport.java
----------------------------------------------------------------------
diff --git 
a/shell/console/src/main/java/org/apache/karaf/shell/console/OsgiCommandSupport.java
 
b/shell/console/src/main/java/org/apache/karaf/shell/console/OsgiCommandSupport.java
index 941fc77..1c68994 100644
--- 
a/shell/console/src/main/java/org/apache/karaf/shell/console/OsgiCommandSupport.java
+++ 
b/shell/console/src/main/java/org/apache/karaf/shell/console/OsgiCommandSupport.java
@@ -64,17 +64,20 @@ public abstract class OsgiCommandSupport extends 
AbstractAction implements Actio
         return services;
     }
 
+    protected <T> T getService(Class<T> clazz, ServiceReference reference) {
+        return (T) getService(reference);
+    }
+
     protected <T> T getService(Class<T> clazz) {
-        ServiceReference<T> sr = getBundleContext().getServiceReference(clazz);
-        if (sr != null) {
-            return getService(clazz, sr);
-        } else {
-            return null;
+        ServiceReference<T> ref = 
getBundleContext().getServiceReference(clazz);
+        if (ref != null) {
+            return getService(ref);
         }
+        return null;
     }
 
-    protected <T> T getService(Class<T> clazz, ServiceReference<T> reference) {
-        T t = getBundleContext().getService(reference);
+    protected <T> T getService(ServiceReference<T> reference) {
+        T t = (T) getBundleContext().getService(reference);
         if (t != null) {
             if (usedReferences == null) {
                 usedReferences = new ArrayList<ServiceReference<?>>();

Reply via email to