in components/camel-directvm/src/main/java/org/apache/camel/karaf/component/directvm/DirectVmProcessor.java [42:82]
public boolean process(final Exchange exchange, final AsyncCallback callback) {
// need to use a copy of the incoming exchange, so we route using this camel context
final Exchange copy = prepareExchange(exchange);
ClassLoader current = Thread.currentThread().getContextClassLoader();
boolean changed = false;
try {
// set TCCL to application context class loader if given
ClassLoader appClassLoader = endpoint.getCamelContext().getApplicationContextClassLoader();
if (appClassLoader != null) {
LOG.trace("Setting Thread ContextClassLoader to {}", appClassLoader);
Thread.currentThread().setContextClassLoader(appClassLoader);
changed = true;
}
final boolean chgd = changed;
return processor.process(copy, new AsyncCallback() {
@Override
public void done(boolean done) {
try {
// restore TCCL if it was changed during processing
if (chgd) {
LOG.trace("Restoring Thread ContextClassLoader to {}", current);
Thread.currentThread().setContextClassLoader(current);
}
// make sure to copy results back
ExchangeHelper.copyResults(exchange, copy);
} finally {
// must call callback when we are done
callback.done(done);
}
}
});
} finally {
// restore TCCL if it was changed during processing
if (changed) {
LOG.trace("Restoring Thread ContextClassLoader to {}", current);
Thread.currentThread().setContextClassLoader(current);
}
}
}