You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2013/12/09 03:11:33 UTC

[29/50] [abbrv] git commit: [CAMEL-7035] Check both symbolic name and bundle version when registering CamelContext in the OSGi service registry.

[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/963b1c3c
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/963b1c3c
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/963b1c3c

Branch: refs/heads/camel-gora
Commit: 963b1c3c964cfe521ff28455dca2e931d6396ac4
Parents: a2e6342
Author: Ioannis Canellos <io...@apache.org>
Authored: Tue Dec 3 18:43:38 2013 +0200
Committer: Ioannis Canellos <io...@apache.org>
Committed: Tue Dec 3 18:43:38 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/963b1c3c/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 909c43f..dd45c19 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
@@ -93,11 +93,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()) {