You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2015/10/03 09:46:39 UTC

[2/2] camel git commit: CAMEL-9144: Fixed Camel Activtor not being able to detect Camel dataformats (likely also languages/components) when using camel-test-blueprint. Have to use the old checkCompact method for that.

CAMEL-9144: Fixed Camel Activtor not being able to detect Camel dataformats (likely also languages/components) when using camel-test-blueprint. Have to use the old checkCompact method for that.


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

Branch: refs/heads/master
Commit: d5f0aefdffc74ac0971b87946a21fe4be8c305b4
Parents: ec46460
Author: Claus Ibsen <da...@apache.org>
Authored: Sat Oct 3 09:39:23 2015 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Sat Oct 3 09:39:23 2015 +0200

----------------------------------------------------------------------
 .../org/apache/camel/impl/osgi/Activator.java   | 25 ++++++++++++++++++++
 1 file changed, 25 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/d5f0aefd/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java b/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java
index e7d3da3..2071912 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/osgi/Activator.java
@@ -251,9 +251,34 @@ public class Activator implements BundleActivator, BundleTrackerCustomizer {
                 }
             }
         }
+
+        // it may be running outside real OSGi container such as when unit testing with camel-test-blueprint
+        // then we need to use a different canSee algorithm that works outside real OSGi
+        if (bundle.getBundleId() > 0) {
+            Bundle root = bundle.getBundleContext().getBundle(0);
+            if (root != null && "org.apache.felix.connect".equals(root.getSymbolicName())) {
+                return checkCompat(bundle, clazz);
+            }
+        }
+
         return false;
     }
 
+    /**
+     * Check if bundle can see the given class used by camel-test-blueprint
+     */
+    protected static boolean checkCompat(Bundle bundle, Class<?> clazz) {
+        // Check bundle compatibility
+        try {
+            if (bundle.loadClass(clazz.getName()) != clazz) {
+                return false;
+            }
+        } catch (Throwable t) {
+            return false;
+        }
+        return true;
+    }
+
     protected static class BundleComponentResolver extends BaseResolver<Component> implements ComponentResolver {
 
         private final Map<String, String> components;