camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [1/3] git commit: CAMEL-7916 Fix the issue that OsgiServiceRegistry.findByTypeWithName doesn't return the service which name property is null
Date Fri, 17 Oct 2014 08:28:13 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.14.x 7f730a86b -> d2758898a


CAMEL-7916 Fix the issue that OsgiServiceRegistry.findByTypeWithName doesn't return the service
which name property is null


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/2141f1cd
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2141f1cd
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2141f1cd

Branch: refs/heads/camel-2.14.x
Commit: 2141f1cd4f064eff2366e2bcf65225809b92faaa
Parents: 7f730a8
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Fri Oct 17 14:10:58 2014 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Fri Oct 17 16:25:32 2014 +0800

----------------------------------------------------------------------
 .../java/org/apache/camel/core/osgi/OsgiServiceRegistry.java    | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/2141f1cd/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiServiceRegistry.java
----------------------------------------------------------------------
diff --git a/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiServiceRegistry.java
b/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiServiceRegistry.java
index c90245f..e1174d4 100644
--- a/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiServiceRegistry.java
+++ b/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiServiceRegistry.java
@@ -90,6 +90,7 @@ public class OsgiServiceRegistry extends LifecycleStrategySupport implements
Reg
 
     public <T> Map<String, T> findByTypeWithName(Class<T> type) {
         Map<String, T> result = new HashMap<String, T>();
+        int count = 0;
         try {
             ServiceReference<?>[] refs = bundleContext.getAllServiceReferences(type.getName(),
null);
             if (refs != null) {
@@ -101,6 +102,10 @@ public class OsgiServiceRegistry extends LifecycleStrategySupport implements
Reg
                             String name = (String)sr.getProperty("name");
                             if (name != null) {
                                 result.put(name , type.cast(service));
+                            } else {
+                                // generate a unique name for it
+                                result.put(type.getSimpleName() + count, type.cast(service));
+                                count++;
                             }
                         }
                     }


Mime
View raw message