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-spring-boot.git


The following commit(s) were added to refs/heads/main by this push:
     new ef077cb61a5 CAMEL-20760: camel-core - Allow to turn on|off RMI 
connector for tooling based debuggers
ef077cb61a5 is described below

commit ef077cb61a5e7caae4aa65e8bfe3d1524f394728
Author: Claus Ibsen <[email protected]>
AuthorDate: Tue May 14 11:01:31 2024 +0200

    CAMEL-20760: camel-core - Allow to turn on|off RMI connector for tooling 
based debuggers
---
 .../camel-debug-starter/src/main/docs/debug.json   | 14 +++++++++++
 .../boot/debug/CamelDebugAutoConfiguration.java    | 15 ++++++-----
 .../debug/CamelDebugConfigurationProperties.java   | 29 ++++++++++++++++++++++
 3 files changed, 52 insertions(+), 6 deletions(-)

diff --git a/components-starter/camel-debug-starter/src/main/docs/debug.json 
b/components-starter/camel-debug-starter/src/main/docs/debug.json
index fb29c30ae23..34a5d0e05ae 100644
--- a/components-starter/camel-debug-starter/src/main/docs/debug.json
+++ b/components-starter/camel-debug-starter/src/main/docs/debug.json
@@ -69,6 +69,20 @@
       "sourceType": 
"org.apache.camel.spring.boot.debug.CamelDebugConfigurationProperties",
       "defaultValue": true
     },
+    {
+      "name": "camel.debug.jmx-connector-enabled",
+      "type": "java.lang.Boolean",
+      "description": "Whether to create JMX connector that allows tooling to 
control the Camel debugger. This is what the IDEA and VSCode tooling is using.",
+      "sourceType": 
"org.apache.camel.spring.boot.debug.CamelDebugConfigurationProperties",
+      "defaultValue": true
+    },
+    {
+      "name": "camel.debug.jmx-connector-port",
+      "type": "java.lang.Integer",
+      "description": "Port number to expose a JMX RMI connector for tooling 
that needs to control the debugger.",
+      "sourceType": 
"org.apache.camel.spring.boot.debug.CamelDebugConfigurationProperties",
+      "defaultValue": 1099
+    },
     {
       "name": "camel.debug.logging-level",
       "type": "org.apache.camel.LoggingLevel",
diff --git 
a/components-starter/camel-debug-starter/src/main/java/org/apache/camel/spring/boot/debug/CamelDebugAutoConfiguration.java
 
b/components-starter/camel-debug-starter/src/main/java/org/apache/camel/spring/boot/debug/CamelDebugAutoConfiguration.java
index 8a0c8033430..3cc332397ef 100644
--- 
a/components-starter/camel-debug-starter/src/main/java/org/apache/camel/spring/boot/debug/CamelDebugAutoConfiguration.java
+++ 
b/components-starter/camel-debug-starter/src/main/java/org/apache/camel/spring/boot/debug/CamelDebugAutoConfiguration.java
@@ -17,7 +17,7 @@
 package org.apache.camel.spring.boot.debug;
 
 import org.apache.camel.CamelContext;
-import org.apache.camel.component.debug.JmxConnectorService;
+import org.apache.camel.impl.debugger.DebuggerJmxConnectorService;
 import org.apache.camel.impl.debugger.DefaultBacklogDebugger;
 import org.apache.camel.spi.BacklogDebugger;
 import org.apache.camel.spring.boot.CamelAutoConfiguration;
@@ -66,6 +66,14 @@ public class CamelDebugAutoConfiguration {
         debugger.setSuspendMode(config.isWaitForAttach());
         debugger.setFallbackTimeout(config.getFallbackTimeout());
 
+        // enable jmx connector if port is set
+        if (config.isJmxConnectorEnabled()) {
+            DebuggerJmxConnectorService connector = new 
DebuggerJmxConnectorService();
+            connector.setCreateConnector(true);
+            connector.setRegistryPort(config.getJmxConnectorPort());
+            camelContext.addService(connector);
+        }
+
         // start debugger after context is started
         camelContext.addLifecycleStrategy(new LifecycleStrategySupport() {
             @Override
@@ -84,11 +92,6 @@ public class CamelDebugAutoConfiguration {
             }
         });
 
-        // to make debugging possible for tooling we need to make it possible 
to do remote JMX connection
-        if (config.isEnabled() || config.isStandby()) {
-            camelContext.addService(new JmxConnectorService());
-        }
-
         camelContext.addService(debugger);
 
         return debugger;
diff --git 
a/components-starter/camel-debug-starter/src/main/java/org/apache/camel/spring/boot/debug/CamelDebugConfigurationProperties.java
 
b/components-starter/camel-debug-starter/src/main/java/org/apache/camel/spring/boot/debug/CamelDebugConfigurationProperties.java
index 03fda00fd62..d91c8b32ff8 100644
--- 
a/components-starter/camel-debug-starter/src/main/java/org/apache/camel/spring/boot/debug/CamelDebugConfigurationProperties.java
+++ 
b/components-starter/camel-debug-starter/src/main/java/org/apache/camel/spring/boot/debug/CamelDebugConfigurationProperties.java
@@ -100,6 +100,19 @@ public class CamelDebugConfigurationProperties {
     @Metadata(label = "advanced", defaultValue = "300")
     private long fallbackTimeout = 300;
 
+    /**
+     * Whether to create JMX connector that allows tooling to control the 
Camel debugger.
+     * This is what the IDEA and VSCode tooling is using.
+     */
+    @Metadata(label = "advanced", defaultValue = "true")
+    private boolean jmxConnectorEnabled = true;
+
+    /**
+     * Port number to expose a JMX RMI connector for tooling that needs to 
control the debugger.
+     */
+    @Metadata(label = "advanced", defaultValue = "1099")
+    private int jmxConnectorPort = 1099;
+
     public boolean isEnabled() {
         return enabled;
     }
@@ -203,4 +216,20 @@ public class CamelDebugConfigurationProperties {
     public void setFallbackTimeout(long fallbackTimeout) {
         this.fallbackTimeout = fallbackTimeout;
     }
+
+    public boolean isJmxConnectorEnabled() {
+        return jmxConnectorEnabled;
+    }
+
+    public void setJmxConnectorEnabled(boolean jmxConnectorEnabled) {
+        this.jmxConnectorEnabled = jmxConnectorEnabled;
+    }
+
+    public int getJmxConnectorPort() {
+        return jmxConnectorPort;
+    }
+
+    public void setJmxConnectorPort(int jmxConnectorPort) {
+        this.jmxConnectorPort = jmxConnectorPort;
+    }
 }

Reply via email to