Author: dkulp
Date: Mon Sep 19 16:44:38 2011
New Revision: 1172694

URL: http://svn.apache.org/viewvc?rev=1172694&view=rev
Log:
Merged revisions 1152733 via svnmerge from 
https://svn.apache.org/repos/asf/camel/trunk

........
  r1152733 | ningjiang | 2011-08-01 06:53:44 -0400 (Mon, 01 Aug 2011) | 1 line
  
  CAMEL-4286 BlueprintCamelContextFactoryBean should set the 
ApplicationContextClassLoader for the CamelContext
........

Modified:
    camel/branches/camel-2.8.x/   (props changed)
    
camel/branches/camel-2.8.x/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
    
camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint4Test.java

Propchange: camel/branches/camel-2.8.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Sep 19 16:44:38 2011
@@ -1 +1 @@
-/camel/trunk:1148706,1148710,1149570,1150651,1151000,1151054,1151087,1151362,1152170,1152755,1153620,1153812,1153829,1154684,1155230,1156108,1156260,1156277,1156479,1156524,1157348,1157749,1157798,1157831,1157878,1158153,1159171,1159174,1159326,1159457,1159460,1159606,1159682-1159683,1159867,1160547,1160637,1161010,1161082,1161524,1162309,1162395,1163231,1163420,1163656-1163669,1163725,1164544,1164557,1164633,1164972-1165000,1165152,1165157,1165658,1165971,1165987,1167098,1167131,1167448,1167487,1167555,1169610,1169620,1170122,1170226,1170397,1170956,1171396,1171755,1171941,1171947
+/camel/trunk:1148706,1148710,1149570,1150651,1151000,1151054,1151087,1151362,1152170,1152733,1152755,1153620,1153812,1153829,1154684,1155230,1156108,1156260,1156277,1156479,1156524,1157348,1157749,1157798,1157831,1157878,1158153,1159171,1159174,1159326,1159457,1159460,1159606,1159682-1159683,1159867,1160547,1160637,1161010,1161082,1161524,1162309,1162395,1163231,1163420,1163656-1163669,1163725,1164544,1164557,1164633,1164972-1165000,1165152,1165157,1165658,1165971,1165987,1167098,1167131,1167448,1167487,1167555,1169610,1169620,1170122,1170226,1170397,1170956,1171396,1171755,1171941,1171947

Propchange: camel/branches/camel-2.8.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: 
camel/branches/camel-2.8.x/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
URL: 
http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java?rev=1172694&r1=1172693&r2=1172694&view=diff
==============================================================================
--- 
camel/branches/camel-2.8.x/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
 (original)
+++ 
camel/branches/camel-2.8.x/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
 Mon Sep 19 16:44:38 2011
@@ -261,6 +261,10 @@ public class CamelContextFactoryBean ext
     @Override
     public void afterPropertiesSet() throws Exception {
         super.afterPropertiesSet();
+        // setup the application context classloader with the bundle 
delegating classloader
+        ClassLoader cl = new 
BundleDelegatingClassLoader(((ExtendedBlueprintContainer) 
blueprintContainer).getBundleContext().getBundle());
+        LOG.debug("Set the application context classloader to: {}", cl);
+        getContext().setApplicationContextClassLoader(cl);
         getContext().getManagementStrategy().addEventNotifier(new 
OsgiCamelContextPublisher(bundleContext));
         try {
             
getClass().getClassLoader().loadClass("org.osgi.service.event.EventAdmin");

Modified: 
camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint4Test.java
URL: 
http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint4Test.java?rev=1172694&r1=1172693&r2=1172694&view=diff
==============================================================================
--- 
camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint4Test.java
 (original)
+++ 
camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/blueprint/CamelBlueprint4Test.java
 Mon Sep 19 16:44:38 2011
@@ -34,6 +34,7 @@ import static org.ops4j.pax.exam.OptionU
 import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.scanFeatures;
 import static 
org.ops4j.pax.exam.container.def.PaxRunnerOptions.workingDirectory;
 import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.newBundle;
+import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.withBnd;
 
 /**
  * @version 
@@ -71,6 +72,20 @@ public class CamelBlueprint4Test extends
         template.stop();
     }
 
+    @Test
+    public void testGetApplicationContextClassloader() throws Exception {
+        getInstalledBundle("CamelBlueprintTestBundle22").start();
+        BlueprintContainer ctn = getOsgiService(BlueprintContainer.class, 
"(osgi.blueprint.container.symbolicname=CamelBlueprintTestBundle22)", 10000);
+        CamelContext ctx = getOsgiService(CamelContext.class, 
"(camel.context.symbolicname=CamelBlueprintTestBundle22)", 10000);
+
+        // test the application context classloader
+        assertNotNull("The application context classloader should not be 
null", ctx.getApplicationContextClassLoader());
+        ClassLoader cl = ctx.getApplicationContextClassLoader();
+        assertNotNull("It should load the TestRouteBuilder class", 
cl.getResource("OSGI-INF/blueprint/test.xml"));
+        assertNotNull("It should load the TestRouteBuilder class", 
cl.loadClass("org.apache.camel.itest.osgi.blueprint.TestRouteBuilder"));
+
+    }
+
     @Configuration
     public static Option[] configure() throws Exception {
 
@@ -89,6 +104,12 @@ public class CamelBlueprint4Test extends
                         .set(Constants.BUNDLE_SYMBOLICNAME, 
"CamelBlueprintTestBundle20")
                         .build()).noStart(),
                 
+                bundle(newBundle()
+                        .add("OSGI-INF/blueprint/test.xml", 
OSGiBlueprintTestSupport.class.getResource("blueprint-13.xml"))
+                        .set(Constants.BUNDLE_SYMBOLICNAME, 
"CamelBlueprintTestBundle22")
+                        .add(TestRouteBuilder.class)
+                        .build(withBnd())).noStart(),
+
                 // using the features to install the camel components
                 scanFeatures(getCamelKarafFeatureUrl(),
                         "camel-blueprint", "camel-velocity"));


Reply via email to