Updated Branches: refs/heads/camel-2.12.x b073e10de -> 6d761ddc1
[CAMEL-7035] Check both symbolic name and bundle version when registering CamelContext in the OSGi service registry. Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/6d761ddc Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/6d761ddc Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/6d761ddc Branch: refs/heads/camel-2.12.x Commit: 6d761ddc1f92991bd462f2232d309c50a677f3f4 Parents: b073e10 Author: Ioannis Canellos <ioca...@apache.org> Authored: Tue Dec 3 18:43:38 2013 +0200 Committer: Ioannis Canellos <ioca...@apache.org> Committed: Tue Dec 3 19:13:06 2013 +0200 ---------------------------------------------------------------------- .../apache/camel/core/osgi/OsgiCamelContextPublisher.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/6d761ddc/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiCamelContextPublisher.java ---------------------------------------------------------------------- diff --git a/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiCamelContextPublisher.java b/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiCamelContextPublisher.java index 7c9ed17..4b0f42d 100644 --- a/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiCamelContextPublisher.java +++ b/components/camel-core-osgi/src/main/java/org/apache/camel/core/osgi/OsgiCamelContextPublisher.java @@ -94,11 +94,15 @@ public class OsgiCamelContextPublisher extends EventNotifierSupport { public ServiceRegistration registerCamelContext(CamelContext camelContext) throws InvalidSyntaxException { // avoid registering the same service again - ServiceReference[] refs = bundleContext.getServiceReferences(CamelContext.class.getName(), "(camel.context.symbolicname=" + bundleContext.getBundle().getSymbolicName() + ")"); + String symbolicName = bundleContext.getBundle().getSymbolicName(); + Version bundleVersion = getBundleVersion(bundleContext.getBundle()); + ServiceReference[] refs = bundleContext.getServiceReferences(CamelContext.class.getName(), + "(&(" + CONTEXT_SYMBOLIC_NAME_PROPERTY + "=" + symbolicName + ")(" + CONTEXT_VERSION_PROPERTY + "=" + bundleVersion + "))"); + if (refs == null) { Dictionary<String, Object > props = new Hashtable<String, Object>(); - props.put(CONTEXT_SYMBOLIC_NAME_PROPERTY, bundleContext.getBundle().getSymbolicName()); - props.put(CONTEXT_VERSION_PROPERTY, getBundleVersion(bundleContext.getBundle())); + props.put(CONTEXT_SYMBOLIC_NAME_PROPERTY, symbolicName); + props.put(CONTEXT_VERSION_PROPERTY, bundleVersion); props.put(CONTEXT_NAME_PROPERTY, camelContext.getName()); if (log.isDebugEnabled()) {