This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit d6f7988ec262822fa9831e16e4d68011b2152805 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Mon May 13 14:09:04 2024 +0200 CAMEL-20762: camel-main - Detect camel-debug JAR on classpath eager to turn on source location which is needed for khaving Java DSL working. --- .../main/java/org/apache/camel/main/BaseMainSupport.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java index 4bfddc7212a..52f5bb07217 100644 --- a/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java +++ b/core/camel-main/src/main/java/org/apache/camel/main/BaseMainSupport.java @@ -65,6 +65,8 @@ import org.apache.camel.spi.CamelTracingService; import org.apache.camel.spi.CompileStrategy; import org.apache.camel.spi.ContextReloadStrategy; import org.apache.camel.spi.DataFormat; +import org.apache.camel.spi.Debugger; +import org.apache.camel.spi.DebuggerFactory; import org.apache.camel.spi.Language; import org.apache.camel.spi.LifecycleStrategy; import org.apache.camel.spi.PackageScanClassResolver; @@ -689,6 +691,8 @@ public abstract class BaseMainSupport extends BaseService { configureLifecycle(camelContext); if (standalone) { + // detect if camel-debug JAR is on classpath as we need to know this before configuring routes + detectCamelDebugJar(camelContext); step = recorder.beginStep(BaseMainSupport.class, "configureRoutes", "Collect Routes"); configureRoutes(camelContext); recorder.endStep(step); @@ -711,6 +715,15 @@ public abstract class BaseMainSupport extends BaseService { } } + protected void detectCamelDebugJar(CamelContext camelContext) { + DebuggerFactory df = camelContext.getCamelContextExtension().getBootstrapFactoryFinder() + .newInstance(Debugger.FACTORY, DebuggerFactory.class).orElse(null); + if (df != null) { + // if camel-debug is on classpath then we need to eager to turn on source location which is needed for Java DSL + camelContext.setSourceLocationEnabled(true); + } + } + protected void autoConfigurationFailFast(CamelContext camelContext, OrderedLocationProperties autoConfiguredProperties) throws Exception { // load properties