Repository: camel Updated Branches: refs/heads/master 130317ac3 -> 08b491d9d
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/73f69d8a Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/73f69d8a Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/73f69d8a Branch: refs/heads/master Commit: 73f69d8a015f0d3095f6b037c2b75c065a454013 Parents: 130317a Author: Willem Jiang <willem.ji...@gmail.com> Authored: Fri Oct 17 14:10:58 2014 +0800 Committer: Willem Jiang <willem.ji...@gmail.com> Committed: Fri Oct 17 14:10:58 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/73f69d8a/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++; } } }