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


The following commit(s) were added to refs/heads/main by this push:
     new 4b410e4a717 CAMEL-20253: camel-jbang - Add support for jolokia 2.x 
(#12848)
4b410e4a717 is described below

commit 4b410e4a717a7aa398f69aac3feff57f7b029b5e
Author: Ivan Kulaga <kulagaivanandreev...@gmail.com>
AuthorDate: Wed Jan 24 14:44:13 2024 +0600

    CAMEL-20253: camel-jbang - Add support for jolokia 2.x (#12848)
    
    Migration guide https://jolokia.org/migration.html does not specify api 
change, so org.apache.camel.dsl.jbang.core.commands.process.Jolokia was left as 
it is.
    JolokiaHttpRequestHandlerSupport is expected to be made more pluggable in 
the future.
---
 .../main/camel-main-configuration-metadata.json    |   1 +
 components/camel-platform-http-main/pom.xml        |   8 ++
 .../http/main/DefaultMainHttpServerFactory.java    |   1 +
 .../platform/http/main/MainHttpServer.java         | 108 +++++++++++++++++++
 .../jolokia/JolokiaHttpRequestHandlerSupport.java  | 119 +++++++++++++++++++++
 .../http/main/MainHttpServerJolokiaTest.java       |  75 +++++++++++++
 ...ttpServerConfigurationPropertiesConfigurer.java |   6 ++
 .../camel-main-configuration-metadata.json         |   1 +
 core/camel-main/src/main/docs/main.adoc            |   3 +-
 .../main/HttpServerConfigurationProperties.java    |  22 ++++
 dsl/camel-jbang/camel-jbang-core/pom.xml           |   2 +-
 parent/pom.xml                                     |   2 +-
 12 files changed, 345 insertions(+), 3 deletions(-)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
index 23395908207..099d60d0bcc 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/main/camel-main-configuration-metadata.json
@@ -250,6 +250,7 @@
     { "name": "camel.server.enabled", "description": "Whether embedded HTTP 
server is enabled. By default, the server is not enabled.", "sourceType": 
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean", 
"javaType": "boolean", "defaultValue": "false" },
     { "name": "camel.server.healthCheckEnabled", "description": "Whether to 
enable health-check console. If enabled then you can access health-check status 
on context-path: \/q\/health", "sourceType": 
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean", 
"javaType": "boolean", "defaultValue": "false" },
     { "name": "camel.server.host", "description": "Hostname to use for binding 
embedded HTTP server", "sourceType": 
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "string", 
"javaType": "java.lang.String", "defaultValue": "0.0.0.0" },
+    { "name": "camel.server.jolokiaEnabled", "description": "Whether to enable 
jolokia. If enabled then you can access jolokia api on context-path: 
\/q\/jolokia", "sourceType": 
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean", 
"javaType": "boolean", "defaultValue": "false" },
     { "name": "camel.server.maxBodySize", "description": "Maximum HTTP body 
size the embedded HTTP server can accept.", "sourceType": 
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "integer", 
"javaType": "java.lang.Long" },
     { "name": "camel.server.metricsEnabled", "description": "Whether to enable 
metrics. If enabled then you can access metrics on context-path: \/q\/metrics", 
"sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", 
"type": "boolean", "javaType": "boolean", "defaultValue": "false" },
     { "name": "camel.server.path", "description": "Context-path to use for 
embedded HTTP server", "sourceType": 
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "string", 
"javaType": "java.lang.String", "defaultValue": "\/" },
diff --git a/components/camel-platform-http-main/pom.xml 
b/components/camel-platform-http-main/pom.xml
index 738b6f39197..0c2d819e2ad 100644
--- a/components/camel-platform-http-main/pom.xml
+++ b/components/camel-platform-http-main/pom.xml
@@ -43,6 +43,14 @@
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-main</artifactId>
         </dependency>
+
+        <!-- jolokia -->
+        <dependency>
+            <groupId>org.jolokia</groupId>
+            <artifactId>jolokia-agent-jvm</artifactId>
+            <version>${jolokia-version}</version>
+        </dependency>
+
         <!-- use vertx as http engine -->
         <dependency>
             <groupId>org.apache.camel</groupId>
diff --git 
a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/DefaultMainHttpServerFactory.java
 
b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/DefaultMainHttpServerFactory.java
index 967e536ba6b..52e769b7b18 100644
--- 
a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/DefaultMainHttpServerFactory.java
+++ 
b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/DefaultMainHttpServerFactory.java
@@ -53,6 +53,7 @@ public class DefaultMainHttpServerFactory implements 
CamelContextAware, MainHttp
         
server.setUseGlobalSslContextParameters(configuration.isUseGlobalSslContextParameters());
         server.setDevConsoleEnabled(configuration.isDevConsoleEnabled());
         server.setHealthCheckEnabled(configuration.isHealthCheckEnabled());
+        server.setJolokiaEnabled(configuration.isJolokiaEnabled());
         server.setMetricsEnabled(configuration.isMetricsEnabled());
         server.setUploadEnabled(configuration.isUploadEnabled());
         server.setUploadSourceDir(configuration.getUploadSourceDir());
diff --git 
a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
 
b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
index 7a830d78bf0..87baeee3ea6 100644
--- 
a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
+++ 
b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/MainHttpServer.java
@@ -18,8 +18,11 @@ package org.apache.camel.component.platform.http.main;
 
 import java.io.File;
 import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
 import java.io.PrintWriter;
 import java.io.StringWriter;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
@@ -31,13 +34,21 @@ import java.util.Set;
 import java.util.TreeSet;
 import java.util.stream.Collectors;
 
+import javax.management.RuntimeMBeanException;
+
+import io.netty.buffer.ByteBufInputStream;
 import io.vertx.core.Handler;
+import io.vertx.core.MultiMap;
+import io.vertx.core.http.HttpHeaders;
 import io.vertx.core.http.HttpMethod;
+import io.vertx.core.http.HttpServerRequest;
+import io.vertx.core.impl.Arguments;
 import io.vertx.ext.web.RequestBody;
 import io.vertx.ext.web.Route;
 import io.vertx.ext.web.RoutingContext;
 import io.vertx.ext.web.handler.BodyHandler;
 import io.vertx.ext.web.impl.BlockingHandlerDecorator;
+import io.vertx.ext.web.impl.Utils;
 import org.apache.camel.CamelContext;
 import org.apache.camel.CamelContextAware;
 import org.apache.camel.Exchange;
@@ -46,6 +57,7 @@ import org.apache.camel.StartupListener;
 import org.apache.camel.StaticService;
 import org.apache.camel.component.platform.http.HttpEndpointModel;
 import org.apache.camel.component.platform.http.PlatformHttpComponent;
+import 
org.apache.camel.component.platform.http.main.jolokia.JolokiaHttpRequestHandlerSupport;
 import org.apache.camel.component.platform.http.vertx.VertxPlatformHttpRouter;
 import org.apache.camel.component.platform.http.vertx.VertxPlatformHttpServer;
 import 
org.apache.camel.component.platform.http.vertx.VertxPlatformHttpServerConfiguration;
@@ -65,6 +77,9 @@ import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.StringHelper;
 import org.apache.camel.util.json.JsonObject;
+import org.jolokia.server.core.http.HttpRequestHandler;
+import org.json.simple.JSONAware;
+import org.json.simple.JSONObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -81,6 +96,7 @@ public class MainHttpServer extends ServiceSupport implements 
CamelContextAware,
     private VertxPlatformHttpServerConfiguration configuration = new 
VertxPlatformHttpServerConfiguration();
     private boolean devConsoleEnabled;
     private boolean healthCheckEnabled;
+    private boolean jolokiaEnabled;
     private boolean metricsEnabled;
     private boolean uploadEnabled;
     private String uploadSourceDir;
@@ -118,6 +134,10 @@ public class MainHttpServer extends ServiceSupport 
implements CamelContextAware,
         return healthCheckEnabled;
     }
 
+    public boolean isJolokiaEnabled() {
+        return jolokiaEnabled;
+    }
+
     /**
      * Whether health-check is enabled (q/health)
      */
@@ -125,6 +145,13 @@ public class MainHttpServer extends ServiceSupport 
implements CamelContextAware,
         this.healthCheckEnabled = healthCheckEnabled;
     }
 
+    /**
+     * Whether jolokia is enabled (q/jolokia)
+     */
+    public void setJolokiaEnabled(boolean jolokiaEnabledEnabled) {
+        this.jolokiaEnabled = jolokiaEnabledEnabled;
+    }
+
     public boolean isMetricsEnabled() {
         return metricsEnabled;
     }
@@ -247,6 +274,9 @@ public class MainHttpServer extends ServiceSupport 
implements CamelContextAware,
         if (healthCheckEnabled) {
             setupHealthCheckConsole();
         }
+        if (jolokiaEnabled) {
+            setupJolokia();
+        }
         if (uploadEnabled) {
             if (uploadSourceDir == null) {
                 throw new IllegalArgumentException("UploadSourceDir must be 
configured when uploadEnabled=true");
@@ -387,6 +417,84 @@ public class MainHttpServer extends ServiceSupport 
implements CamelContextAware,
         platformHttpComponent.addHttpEndpoint("/q/health", null, null);
     }
 
+    protected void setupJolokia() {
+        Route jolokia = router.route("/q/jolokia/*");
+        jolokia.method(HttpMethod.GET);
+        jolokia.method(HttpMethod.POST);
+
+        Handler<RoutingContext> handler = routingContext -> {
+
+            HttpServerRequest req = routingContext.request();
+            String remainingPath = Utils.pathOffset(req.path(), 
routingContext);
+
+            HttpRequestHandler requestHandler = getHttpRequestHandler();
+
+            JSONAware json = null;
+            try {
+                requestHandler.checkAccess(req.remoteAddress().host(), 
req.remoteAddress().host(), getOriginOrReferer(req));
+                if (req.method() == HttpMethod.GET) {
+                    json = requestHandler.handleGetRequest(req.uri(), 
remainingPath, getParams(req.params()));
+                } else {
+                    Arguments.require(routingContext.body() != null, "Missing 
body");
+                    InputStream inputStream = new 
ByteBufInputStream(routingContext.body().buffer().getByteBuf());
+                    json = requestHandler.handlePostRequest(req.uri(), 
inputStream, StandardCharsets.UTF_8.name(),
+                            getParams(req.params()));
+                }
+            } catch (Throwable exp) {
+                json = requestHandler.handleThrowable(
+                        exp instanceof RuntimeMBeanException ? 
((RuntimeMBeanException) exp).getTargetException() : exp);
+            } finally {
+                if (json == null)
+                    json = requestHandler.handleThrowable(new 
Exception("Internal error while handling an exception"));
+
+                routingContext.response()
+                        .setStatusCode(getStatusCode(json))
+                        .putHeader(HttpHeaders.CONTENT_TYPE, 
"application/json")
+                        .end(json.toJSONString());
+            }
+        };
+
+        jolokia.handler(new BlockingHandlerDecorator(handler, true));
+
+        platformHttpComponent.addHttpEndpoint("/q/jolokia", null, null);
+    }
+
+    private HttpRequestHandler getHttpRequestHandler() {
+        //TODO: make jolokiaService more pluggable
+        //JolokiaHttpRequestHandlerSupport jolokiaService = 
camelContext.getCamelContextExtension().getContextPlugin(JolokiaHttpRequestHandlerSupport.class);
+        HttpRequestHandler requestHandler;
+        try (JolokiaHttpRequestHandlerSupport jolokiaService = new 
JolokiaHttpRequestHandlerSupport()) {
+            jolokiaService.start();
+            requestHandler = jolokiaService.getHttpRequestHandler();
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        }
+        return requestHandler;
+    }
+
+    private Map<String, String[]> getParams(MultiMap params) {
+        Map<String, String[]> response = new HashMap<>();
+        for (String name : params.names()) {
+            response.put(name, params.getAll(name).toArray(new String[0]));
+        }
+        return response;
+    }
+
+    private String getOriginOrReferer(HttpServerRequest req) {
+        String origin = req.getHeader(HttpHeaders.ORIGIN);
+        if (origin == null) {
+            origin = req.getHeader(HttpHeaders.REFERER);
+        }
+        return origin != null ? origin.replaceAll("[\\n\\r]*", "") : null;
+    }
+
+    protected int getStatusCode(JSONAware json) {
+        if (json instanceof JSONObject && ((JSONObject) json).get("status") 
instanceof Integer) {
+            return (Integer) ((JSONObject) json).get("status");
+        }
+        return 200;
+    }
+
     @Override
     protected void doStop() throws Exception {
         ServiceHelper.stopAndShutdownService(server);
diff --git 
a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/jolokia/JolokiaHttpRequestHandlerSupport.java
 
b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/jolokia/JolokiaHttpRequestHandlerSupport.java
new file mode 100644
index 00000000000..0bfedb1aff8
--- /dev/null
+++ 
b/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/jolokia/JolokiaHttpRequestHandlerSupport.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.platform.http.main.jolokia;
+
+import java.io.IOException;
+
+import org.apache.camel.StaticService;
+import org.apache.camel.support.service.ServiceSupport;
+import org.jolokia.server.core.config.ConfigKey;
+import org.jolokia.server.core.config.StaticConfiguration;
+import org.jolokia.server.core.http.HttpRequestHandler;
+import org.jolokia.server.core.restrictor.AllowAllRestrictor;
+import org.jolokia.server.core.restrictor.DenyAllRestrictor;
+import org.jolokia.server.core.restrictor.RestrictorFactory;
+import org.jolokia.server.core.service.JolokiaServiceManagerFactory;
+import org.jolokia.server.core.service.api.JolokiaServiceManager;
+import org.jolokia.server.core.service.api.LogHandler;
+import org.jolokia.server.core.service.api.Restrictor;
+import org.jolokia.server.core.util.NetworkUtil;
+import org.jolokia.service.jmx.LocalRequestHandler;
+import org.jolokia.service.serializer.JolokiaSerializer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class JolokiaHttpRequestHandlerSupport extends ServiceSupport 
implements StaticService {
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(JolokiaHttpRequestHandlerSupport.class);
+
+    private final JolokiaServiceManager serviceManager;
+
+    private HttpRequestHandler requestHandler;
+
+    private final LogHandler jolokiaLogHandler;
+
+    public JolokiaHttpRequestHandlerSupport() {
+        var config = new StaticConfiguration(ConfigKey.AGENT_ID, 
NetworkUtil.getAgentId(hashCode(), "vertx"));
+        jolokiaLogHandler = new JolokiaLogHandler(LOG);
+        var restrictor = 
createRestrictor(NetworkUtil.replaceExpression(config.getConfig(ConfigKey.POLICY_LOCATION)));
+
+        serviceManager = 
JolokiaServiceManagerFactory.createJolokiaServiceManager(
+                config,
+                jolokiaLogHandler,
+                restrictor);
+        serviceManager.addService(new JolokiaSerializer());
+        serviceManager.addService(new LocalRequestHandler(1));
+
+        LOG.info("Creating JolokiaHttpRequestHandlerSupport with restrictor " 
+ restrictor);
+    }
+
+    @Override
+    public void start() {
+        var jolokiaContext = serviceManager.start();
+        requestHandler = new HttpRequestHandler(jolokiaContext);
+    }
+
+    @Override
+    public void stop() {
+        serviceManager.stop();
+    }
+
+    public HttpRequestHandler getHttpRequestHandler() {
+        return requestHandler;
+    }
+
+    private Restrictor createRestrictor(String pLocation) {
+        try {
+            var restrictor = 
RestrictorFactory.lookupPolicyRestrictor(pLocation);
+            if (restrictor != null) {
+                jolokiaLogHandler.info("Using access restrictor " + pLocation);
+                return restrictor;
+            } else {
+                jolokiaLogHandler.info("No access restrictor found at " + 
pLocation + ", access to all MBeans is allowed");
+                return new AllowAllRestrictor();
+            }
+        } catch (IOException e) {
+            jolokiaLogHandler.error("Error while accessing access restrictor 
at " + pLocation +
+                            ". Denying all access to MBeans for security 
reasons. Exception: " + e,
+                    e);
+            return new DenyAllRestrictor();
+        }
+    }
+
+    private record JolokiaLogHandler(Logger log) implements LogHandler {
+
+        @Override
+        public void debug(String message) {
+            log.debug(message);
+        }
+
+        @Override
+        public void info(String message) {
+            log.info(message);
+        }
+
+        @Override
+        public void error(String message, Throwable t) {
+            log.error(message, t);
+        }
+
+        @Override
+        public boolean isDebug() {
+            return log.isDebugEnabled();
+        }
+    }
+}
diff --git 
a/components/camel-platform-http-main/src/test/java/org/apache/camel/component/platform/http/main/MainHttpServerJolokiaTest.java
 
b/components/camel-platform-http-main/src/test/java/org/apache/camel/component/platform/http/main/MainHttpServerJolokiaTest.java
new file mode 100644
index 00000000000..b328dbcb694
--- /dev/null
+++ 
b/components/camel-platform-http-main/src/test/java/org/apache/camel/component/platform/http/main/MainHttpServerJolokiaTest.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.platform.http.main;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.http.HttpClient;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.test.AvailablePortFinder;
+import org.json.simple.JSONObject;
+import org.json.simple.parser.JSONParser;
+import org.json.simple.parser.ParseException;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class MainHttpServerJolokiaTest {
+
+    private CamelContext camelContext;
+
+    private final int port = AvailablePortFinder.getNextAvailable();
+
+    @Test
+    public void jolokiaIsUp() throws IOException, InterruptedException, 
ParseException {
+        MainHttpServer server = new MainHttpServer();
+
+        camelContext = new DefaultCamelContext();
+        server.setCamelContext(camelContext);
+
+        server.setHost("0.0.0.0");
+        server.setPort(port);
+        server.setPath("/");
+
+        server.setJolokiaEnabled(true);
+        server.start();
+
+        HttpRequest httpRequest = HttpRequest.newBuilder()
+                .uri(URI.create("http://localhost:"; + port + "/q/jolokia"))
+                .build();
+
+        HttpResponse<String> response = 
HttpClient.newBuilder().build().send(httpRequest, 
HttpResponse.BodyHandlers.ofString());
+        JSONParser parser = new JSONParser();
+        JSONObject responseBody = (JSONObject) parser.parse(response.body());
+
+        JSONObject value = (JSONObject) responseBody.get("value");
+        String agentVersion = (String) value.get("agent");
+
+        JSONObject request = (JSONObject) responseBody.get("request");
+        String type = (String) request.get("type");
+
+        assertEquals(200, response.statusCode());
+        assertEquals("version", type);
+        assertEquals("2.0.0", agentVersion);
+    }
+
+}
diff --git 
a/core/camel-main/src/generated/java/org/apache/camel/main/HttpServerConfigurationPropertiesConfigurer.java
 
b/core/camel-main/src/generated/java/org/apache/camel/main/HttpServerConfigurationPropertiesConfigurer.java
index 7479623930b..badbe6fed5c 100644
--- 
a/core/camel-main/src/generated/java/org/apache/camel/main/HttpServerConfigurationPropertiesConfigurer.java
+++ 
b/core/camel-main/src/generated/java/org/apache/camel/main/HttpServerConfigurationPropertiesConfigurer.java
@@ -29,6 +29,8 @@ public class HttpServerConfigurationPropertiesConfigurer 
extends org.apache.came
         case "HealthCheckEnabled": 
target.setHealthCheckEnabled(property(camelContext, boolean.class, value)); 
return true;
         case "host":
         case "Host": target.setHost(property(camelContext, 
java.lang.String.class, value)); return true;
+        case "jolokiaenabled":
+        case "JolokiaEnabled": target.setJolokiaEnabled(property(camelContext, 
boolean.class, value)); return true;
         case "maxbodysize":
         case "MaxBodySize": target.setMaxBodySize(property(camelContext, 
java.lang.Long.class, value)); return true;
         case "metricsenabled":
@@ -58,6 +60,8 @@ public class HttpServerConfigurationPropertiesConfigurer 
extends org.apache.came
         case "HealthCheckEnabled": return boolean.class;
         case "host":
         case "Host": return java.lang.String.class;
+        case "jolokiaenabled":
+        case "JolokiaEnabled": return boolean.class;
         case "maxbodysize":
         case "MaxBodySize": return java.lang.Long.class;
         case "metricsenabled":
@@ -88,6 +92,8 @@ public class HttpServerConfigurationPropertiesConfigurer 
extends org.apache.came
         case "HealthCheckEnabled": return target.isHealthCheckEnabled();
         case "host":
         case "Host": return target.getHost();
+        case "jolokiaenabled":
+        case "JolokiaEnabled": return target.isJolokiaEnabled();
         case "maxbodysize":
         case "MaxBodySize": return target.getMaxBodySize();
         case "metricsenabled":
diff --git 
a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
 
b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
index 23395908207..099d60d0bcc 100644
--- 
a/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
+++ 
b/core/camel-main/src/generated/resources/META-INF/camel-main-configuration-metadata.json
@@ -250,6 +250,7 @@
     { "name": "camel.server.enabled", "description": "Whether embedded HTTP 
server is enabled. By default, the server is not enabled.", "sourceType": 
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean", 
"javaType": "boolean", "defaultValue": "false" },
     { "name": "camel.server.healthCheckEnabled", "description": "Whether to 
enable health-check console. If enabled then you can access health-check status 
on context-path: \/q\/health", "sourceType": 
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean", 
"javaType": "boolean", "defaultValue": "false" },
     { "name": "camel.server.host", "description": "Hostname to use for binding 
embedded HTTP server", "sourceType": 
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "string", 
"javaType": "java.lang.String", "defaultValue": "0.0.0.0" },
+    { "name": "camel.server.jolokiaEnabled", "description": "Whether to enable 
jolokia. If enabled then you can access jolokia api on context-path: 
\/q\/jolokia", "sourceType": 
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "boolean", 
"javaType": "boolean", "defaultValue": "false" },
     { "name": "camel.server.maxBodySize", "description": "Maximum HTTP body 
size the embedded HTTP server can accept.", "sourceType": 
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "integer", 
"javaType": "java.lang.Long" },
     { "name": "camel.server.metricsEnabled", "description": "Whether to enable 
metrics. If enabled then you can access metrics on context-path: \/q\/metrics", 
"sourceType": "org.apache.camel.main.HttpServerConfigurationProperties", 
"type": "boolean", "javaType": "boolean", "defaultValue": "false" },
     { "name": "camel.server.path", "description": "Context-path to use for 
embedded HTTP server", "sourceType": 
"org.apache.camel.main.HttpServerConfigurationProperties", "type": "string", 
"javaType": "java.lang.String", "defaultValue": "\/" },
diff --git a/core/camel-main/src/main/docs/main.adoc 
b/core/camel-main/src/main/docs/main.adoc
index 45bfa21a833..cc34a460ad7 100644
--- a/core/camel-main/src/main/docs/main.adoc
+++ b/core/camel-main/src/main/docs/main.adoc
@@ -166,7 +166,7 @@ The camel.routecontroller supports 12 options, which are 
listed below.
 
 
 === Camel Embedded HTTP Server (only for standalone; not Spring Boot or 
Quarkus) configurations
-The camel.server supports 11 options, which are listed below.
+The camel.server supports 12 options, which are listed below.
 
 [width="100%",cols="2,5,^1,2",options="header"]
 |===
@@ -175,6 +175,7 @@ The camel.server supports 11 options, which are listed 
below.
 | *camel.server.enabled* | Whether embedded HTTP server is enabled. By 
default, the server is not enabled. | false | boolean
 | *camel.server.healthCheck{zwsp}Enabled* | Whether to enable health-check 
console. If enabled then you can access health-check status on context-path: 
/q/health | false | boolean
 | *camel.server.host* | Hostname to use for binding embedded HTTP server | 
0.0.0.0 | String
+| *camel.server.jolokiaEnabled* | Whether to enable jolokia. If enabled then 
you can access jolokia api on context-path: /q/jolokia | false | boolean
 | *camel.server.maxBodySize* | Maximum HTTP body size the embedded HTTP server 
can accept. |  | Long
 | *camel.server.metricsEnabled* | Whether to enable metrics. If enabled then 
you can access metrics on context-path: /q/metrics | false | boolean
 | *camel.server.path* | Context-path to use for embedded HTTP server | / | 
String
diff --git 
a/core/camel-main/src/main/java/org/apache/camel/main/HttpServerConfigurationProperties.java
 
b/core/camel-main/src/main/java/org/apache/camel/main/HttpServerConfigurationProperties.java
index 31ca9b144ec..322bdde54ae 100644
--- 
a/core/camel-main/src/main/java/org/apache/camel/main/HttpServerConfigurationProperties.java
+++ 
b/core/camel-main/src/main/java/org/apache/camel/main/HttpServerConfigurationProperties.java
@@ -41,6 +41,7 @@ public class HttpServerConfigurationProperties implements 
BootstrapCloseable {
 
     private boolean devConsoleEnabled;
     private boolean healthCheckEnabled;
+    private boolean jolokiaEnabled;
     private boolean metricsEnabled;
     private boolean uploadEnabled;
     private String uploadSourceDir;
@@ -150,6 +151,18 @@ public class HttpServerConfigurationProperties implements 
BootstrapCloseable {
         this.healthCheckEnabled = healthCheckEnabled;
     }
 
+    public boolean isJolokiaEnabled() {
+        return jolokiaEnabled;
+    }
+
+    /**
+     * Whether to enable jolokia. If enabled then you can access jolokia api 
on context-path:
+     * /q/jolokia
+     */
+    public void setJolokiaEnabled(boolean jolokiaEnabled) {
+        this.jolokiaEnabled = jolokiaEnabled;
+    }
+
     public boolean isMetricsEnabled() {
         return metricsEnabled;
     }
@@ -254,6 +267,15 @@ public class HttpServerConfigurationProperties implements 
BootstrapCloseable {
         return this;
     }
 
+    /**
+     * Whether to enable jolokia. If enabled then you can access jolokia api 
on context-path:
+     * /q/jolokia
+     */
+    public HttpServerConfigurationProperties withJolokiaEnabled(boolean 
jolokiaEnabled) {
+        this.jolokiaEnabled = jolokiaEnabled;
+        return this;
+    }
+
     /**
      * Whether to enable metrics. If enabled then you can access metrics on 
context-path: /q/metrics
      */
diff --git a/dsl/camel-jbang/camel-jbang-core/pom.xml 
b/dsl/camel-jbang/camel-jbang-core/pom.xml
index 415ade86ff1..8f60b77093a 100644
--- a/dsl/camel-jbang/camel-jbang-core/pom.xml
+++ b/dsl/camel-jbang/camel-jbang-core/pom.xml
@@ -90,7 +90,7 @@
         <!-- jolokia -->
         <dependency>
             <groupId>org.jolokia</groupId>
-            <artifactId>jolokia-jvm</artifactId>
+            <artifactId>jolokia-agent-jvm</artifactId>
             <version>${jolokia-version}</version>
         </dependency>
         <!-- servlet for launching hawtio -->
diff --git a/parent/pom.xml b/parent/pom.xml
index 2e02c5650e9..d9f9cf5ebc8 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -268,7 +268,7 @@
         <jira-rest-client-api-version>5.2.7</jira-rest-client-api-version>
         <libthrift-version>0.19.0</libthrift-version>
         <jodatime2-version>2.12.6</jodatime2-version>
-        <jolokia-version>1.7.2</jolokia-version>
+        <jolokia-version>2.0.0</jolokia-version>
         <jolt-version>0.1.8</jolt-version>
         <jool-version>0.9.15</jool-version>
         <jooq-version>3.19.3</jooq-version>

Reply via email to