You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by he...@apache.org on 2014/02/18 21:25:45 UTC

git commit: [CAMEL-7218] Changed activator class loading in PlatformHelper.

Repository: camel
Updated Branches:
  refs/heads/master 9fefab66c -> 9477c5775


[CAMEL-7218] Changed activator class loading in PlatformHelper.


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

Branch: refs/heads/master
Commit: 9477c5775c59756649f69c7866a5e185eb191ae3
Parents: 9fefab6
Author: Henryk Konsek <he...@gmail.com>
Authored: Tue Feb 18 21:25:26 2014 +0100
Committer: Henryk Konsek <he...@gmail.com>
Committed: Tue Feb 18 21:25:26 2014 +0100

----------------------------------------------------------------------
 .../org/apache/camel/util/PlatformHelper.java   |  4 ++-
 .../apache/camel/util/PlatformHelperTest.java   | 31 ++++++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/9477c577/camel-core/src/main/java/org/apache/camel/util/PlatformHelper.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/PlatformHelper.java b/camel-core/src/main/java/org/apache/camel/util/PlatformHelper.java
index 3fd0338..438af11 100644
--- a/camel-core/src/main/java/org/apache/camel/util/PlatformHelper.java
+++ b/camel-core/src/main/java/org/apache/camel/util/PlatformHelper.java
@@ -18,6 +18,8 @@ package org.apache.camel.util;
 
 import java.lang.reflect.Method;
 
+import static java.lang.Thread.currentThread;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -41,7 +43,7 @@ public final class PlatformHelper {
         try {
             // Try to load the BundleActivator first
             Class.forName("org.osgi.framework.BundleActivator");
-            Class<?> activatorClass = Class.forName("org.apache.camel.osgi.Activator");
+            Class<?> activatorClass = currentThread().getContextClassLoader().loadClass("org.apache.camel.osgi.Activator");
             Method getBundleMethod = activatorClass.getDeclaredMethod("getBundle");
             Object bundle = getBundleMethod.invoke(null);
             return bundle != null;

http://git-wip-us.apache.org/repos/asf/camel/blob/9477c577/camel-core/src/test/java/org/apache/camel/util/PlatformHelperTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/util/PlatformHelperTest.java b/camel-core/src/test/java/org/apache/camel/util/PlatformHelperTest.java
new file mode 100644
index 0000000..72fbec0
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/util/PlatformHelperTest.java
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.util;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import static org.apache.camel.util.PlatformHelper.isInOsgiEnvironment;
+
+public class PlatformHelperTest extends Assert {
+
+    @Test
+    public void shouldNotFindOsgiContext() {
+        assertFalse(isInOsgiEnvironment());
+    }
+
+}
\ No newline at end of file