Author: ningjiang Date: Fri Apr 26 01:34:28 2013 New Revision: 1476014 URL: http://svn.apache.org/r1476014 Log: CAMEL-6310 BlueprintCamelContext start() method should setup the TCCL Merged revisions 1471425 via svnmerge from https://svn.apache.org/repos/asf/camel/branches/camel-2.11.x
................ r1471425 | ningjiang | 2013-04-24 22:14:48 +0800 (Wed, 24 Apr 2013) | 10 lines Merged revisions 1471407 via svnmerge from https://svn.apache.org/repos/asf/camel/trunk ........ r1471407 | ningjiang | 2013-04-24 21:33:25 +0800 (Wed, 24 Apr 2013) | 1 line CAMEL-6310 BlueprintCamelContext start() method should setup the TCCL ........ ................ Modified: camel/branches/camel-2.10.x/ (props changed) camel/branches/camel-2.10.x/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintCamelContext.java camel/branches/camel-2.10.x/components/camel-jms/ (props changed) Propchange: camel/branches/camel-2.10.x/ ------------------------------------------------------------------------------ Merged /camel/trunk:r1471407 Merged /camel/branches/camel-2.11.x:r1471425 Propchange: camel/branches/camel-2.10.x/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: camel/branches/camel-2.10.x/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintCamelContext.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintCamelContext.java?rev=1476014&r1=1476013&r2=1476014&view=diff ============================================================================== --- camel/branches/camel-2.10.x/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintCamelContext.java (original) +++ camel/branches/camel-2.10.x/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/BlueprintCamelContext.java Fri Apr 26 01:34:28 2013 @@ -25,20 +25,24 @@ import org.apache.camel.core.osgi.utils. import org.apache.camel.impl.DefaultCamelContext; import org.apache.camel.spi.FactoryFinder; import org.apache.camel.spi.Registry; +import org.apache.camel.util.ObjectHelper; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceEvent; import org.osgi.framework.ServiceListener; +import org.osgi.framework.ServiceReference; import org.osgi.framework.ServiceRegistration; import org.osgi.service.blueprint.container.BlueprintContainer; import org.osgi.service.blueprint.container.BlueprintEvent; import org.osgi.service.blueprint.container.BlueprintListener; +import org.osgi.service.cm.Configuration; +import org.osgi.service.cm.ConfigurationAdmin; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class BlueprintCamelContext extends DefaultCamelContext implements ServiceListener, BlueprintListener { private static final transient Logger LOG = LoggerFactory.getLogger(BlueprintCamelContext.class); - + private BundleContext bundleContext; private BlueprintContainer blueprintContainer; private ServiceRegistration registration; @@ -75,7 +79,7 @@ public class BlueprintCamelContext exten public void setBlueprintContainer(BlueprintContainer blueprintContainer) { this.blueprintContainer = blueprintContainer; } - + public void init() throws Exception { LOG.trace("init {}", this); @@ -148,23 +152,32 @@ public class BlueprintCamelContext exten Registry reg = new BlueprintContainerRegistry(getBlueprintContainer()); return OsgiCamelContextHelper.wrapRegistry(this, reg, bundleContext); } + + @Override + public void start() throws Exception { + final ClassLoader original = Thread.currentThread().getContextClassLoader(); + try { + // let's set a more suitable TCCL while starting the context + Thread.currentThread().setContextClassLoader(getApplicationContextClassLoader()); + super.start(); + } finally { + Thread.currentThread().setContextClassLoader(original); + } + } private void maybeStart() throws Exception { LOG.trace("maybeStart: {}", this); - + // for example from unit testing we want to start Camel later and not + // when blueprint loading the bundle if (!isStarted() && !isStarting()) { - final ClassLoader original = Thread.currentThread().getContextClassLoader(); - try { - // let's set a more suitable TCCL while starting the context - Thread.currentThread().setContextClassLoader(getApplicationContextClassLoader()); - LOG.debug("Starting {}", this); - start(); - } finally { - Thread.currentThread().setContextClassLoader(original); - } + LOG.debug("Starting {}", this); + start(); } else { // ignore as Camel is already started LOG.trace("Ignoring maybeStart() as {} is already started", this); } + } + + } Propchange: camel/branches/camel-2.10.x/components/camel-jms/ ('svn:mergeinfo' removed)
