diff --git a/bom/camel-bom/pom.xml b/bom/camel-bom/pom.xml
index 79c7195516dea..8326f57cef927 100644
--- a/bom/camel-bom/pom.xml
+++ b/bom/camel-bom/pom.xml
@@ -1547,6 +1547,11 @@
camel-platform-http
${project.version}
+
+ org.apache.camel
+ camel-platform-http-jolokia
+ ${project.version}
+
org.apache.camel
camel-platform-http-main
diff --git a/catalog/camel-allcomponents/pom.xml b/catalog/camel-allcomponents/pom.xml
index 1ad44fb6a603b..b4902a65b02bf 100644
--- a/catalog/camel-allcomponents/pom.xml
+++ b/catalog/camel-allcomponents/pom.xml
@@ -1342,6 +1342,11 @@
camel-platform-http
${project.version}
+
+ org.apache.camel
+ camel-platform-http-jolokia
+ ${project.version}
+
org.apache.camel
camel-platform-http-main
diff --git a/components/camel-platform-http-jolokia/pom.xml b/components/camel-platform-http-jolokia/pom.xml
new file mode 100644
index 0000000000000..974b51fc0b293
--- /dev/null
+++ b/components/camel-platform-http-jolokia/pom.xml
@@ -0,0 +1,95 @@
+
+
+
+ 4.0.0
+
+
+ org.apache.camel
+ components
+ 4.5.0-SNAPSHOT
+
+
+ camel-platform-http-jolokia
+ jar
+
+ Camel :: Platform HTTP :: Jolokia
+ Jolokia plugin for standalone Camel HTTP Platform
+
+
+ 4.5.0
+
+
+
+
+
+
+ org.apache.camel
+ camel-support
+
+
+ org.apache.camel
+ camel-platform-http
+
+
+
+
+ org.apache.camel
+ camel-util-json
+
+
+
+
+ org.apache.camel
+ camel-core
+ test-jar
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter
+ test
+
+
+ org.hamcrest
+ hamcrest
+ ${hamcrest-version}
+ test
+
+
+ org.assertj
+ assertj-core
+ ${assertj-version}
+ test
+
+
+
+
+ org.apache.logging.log4j
+ log4j-core
+ test
+
+
+ org.apache.logging.log4j
+ log4j-slf4j2-impl
+ test
+
+
+
+
diff --git a/components/camel-platform-http-jolokia/src/generated/resources/META-INF/services/org/apache/camel/component/platform/http/plugin/camel-platform-http-jolokia b/components/camel-platform-http-jolokia/src/generated/resources/META-INF/services/org/apache/camel/component/platform/http/plugin/camel-platform-http-jolokia
new file mode 100644
index 0000000000000..0a5eddbdad4b1
--- /dev/null
+++ b/components/camel-platform-http-jolokia/src/generated/resources/META-INF/services/org/apache/camel/component/platform/http/plugin/camel-platform-http-jolokia
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.component.platform.http.plugin.DefaultJolokiaPlatformHttpPlugin
\ No newline at end of file
diff --git a/components/camel-platform-http-jolokia/src/generated/resources/META-INF/services/org/apache/camel/other.properties b/components/camel-platform-http-jolokia/src/generated/resources/META-INF/services/org/apache/camel/other.properties
new file mode 100644
index 0000000000000..4ec5cad995460
--- /dev/null
+++ b/components/camel-platform-http-jolokia/src/generated/resources/META-INF/services/org/apache/camel/other.properties
@@ -0,0 +1,7 @@
+# Generated by camel build tools - do NOT edit this file!
+name=platform-http-jolokia
+groupId=org.apache.camel
+artifactId=camel-platform-http-jolokia
+version=4.5.0-SNAPSHOT
+projectName=Camel :: Platform HTTP :: Jolokia
+projectDescription=Jolokia plugin for standalone Camel HTTP Platform
diff --git a/components/camel-platform-http-jolokia/src/generated/resources/platform-http-jolokia.json b/components/camel-platform-http-jolokia/src/generated/resources/platform-http-jolokia.json
new file mode 100644
index 0000000000000..1d6ac0f464cc3
--- /dev/null
+++ b/components/camel-platform-http-jolokia/src/generated/resources/platform-http-jolokia.json
@@ -0,0 +1,15 @@
+{
+ "other": {
+ "kind": "other",
+ "name": "platform-http-jolokia",
+ "title": "Platform Http Jolokia",
+ "description": "Jolokia plugin for standalone Camel HTTP Platform",
+ "deprecated": false,
+ "firstVersion": "4.4.0",
+ "label": "http,monitoring",
+ "supportLevel": "Preview",
+ "groupId": "org.apache.camel",
+ "artifactId": "camel-platform-http-jolokia",
+ "version": "4.4.0-SNAPSHOT"
+ }
+}
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-jolokia/src/main/java/org/apache/camel/component/platform/http/plugin/DefaultJolokiaPlatformHttpPlugin.java
similarity index 77%
rename from components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/jolokia/JolokiaHttpRequestHandlerSupport.java
rename to components/camel-platform-http-jolokia/src/main/java/org/apache/camel/component/platform/http/plugin/DefaultJolokiaPlatformHttpPlugin.java
index 6fd001ed0304d..55cd5abe6f1b0 100644
--- a/components/camel-platform-http-main/src/main/java/org/apache/camel/component/platform/http/main/jolokia/JolokiaHttpRequestHandlerSupport.java
+++ b/components/camel-platform-http-jolokia/src/main/java/org/apache/camel/component/platform/http/plugin/DefaultJolokiaPlatformHttpPlugin.java
@@ -14,11 +14,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.component.platform.http.main.jolokia;
+package org.apache.camel.component.platform.http.plugin;
import java.io.IOException;
-import org.apache.camel.StaticService;
+import org.apache.camel.CamelContext;
+import org.apache.camel.spi.annotations.JdkService;
import org.apache.camel.support.service.ServiceSupport;
import org.jolokia.server.core.config.ConfigKey;
import org.jolokia.server.core.config.StaticConfiguration;
@@ -36,9 +37,10 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class JolokiaHttpRequestHandlerSupport extends ServiceSupport implements StaticService {
+@JdkService(DefaultJolokiaPlatformHttpPlugin.NAME)
+public class DefaultJolokiaPlatformHttpPlugin extends ServiceSupport implements JolokiaPlatformHttpPlugin {
- private static final Logger LOG = LoggerFactory.getLogger(JolokiaHttpRequestHandlerSupport.class);
+ private static final Logger LOG = LoggerFactory.getLogger(DefaultJolokiaPlatformHttpPlugin.class);
private final JolokiaServiceManager serviceManager;
@@ -46,7 +48,9 @@ public class JolokiaHttpRequestHandlerSupport extends ServiceSupport implements
private final LogHandler jolokiaLogHandler;
- public JolokiaHttpRequestHandlerSupport() {
+ private CamelContext camelContext;
+
+ public DefaultJolokiaPlatformHttpPlugin() {
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)));
@@ -58,21 +62,24 @@ public JolokiaHttpRequestHandlerSupport() {
serviceManager.addService(new JolokiaSerializer());
serviceManager.addService(new LocalRequestHandler(1));
- LOG.info("Creating JolokiaHttpRequestHandlerSupport with restrictor {}", restrictor);
+ LOG.info("Creating DefaultJolokiaPlatformHttpPlugin with restrictor {}", restrictor);
}
@Override
- public void start() {
+ public void doStart() {
var jolokiaContext = serviceManager.start();
requestHandler = new HttpRequestHandler(jolokiaContext);
}
@Override
- public void stop() {
- serviceManager.stop();
+ public void doStop() {
+ if (serviceManager != null) {
+ serviceManager.stop();
+ }
}
- public HttpRequestHandler getHttpRequestHandler() {
+ @Override
+ public HttpRequestHandler getRequestHandler() {
return requestHandler;
}
@@ -88,12 +95,27 @@ private Restrictor createRestrictor(String pLocation) {
}
} catch (IOException e) {
jolokiaLogHandler.error("Error while accessing access restrictor at " + pLocation +
- ". Denying all access to MBeans for security reasons. Exception: " + e,
+ ". Denying all access to MBeans for security reasons. Exception: " + e,
e);
return new DenyAllRestrictor();
}
}
+ @Override
+ public String getId() {
+ return NAME;
+ }
+
+ @Override
+ public void setCamelContext(CamelContext camelContext) {
+ this.camelContext = camelContext;
+ }
+
+ @Override
+ public CamelContext getCamelContext() {
+ return camelContext;
+ }
+
private record JolokiaLogHandler(Logger log) implements LogHandler {
@Override
@@ -116,4 +138,5 @@ public boolean isDebug() {
return log.isDebugEnabled();
}
}
+
}
diff --git a/components/camel-platform-http-jolokia/src/test/java/org/apache/camel/component/platform/http/plugin/DefaultJolokiaPlatformHttpPluginTest.java b/components/camel-platform-http-jolokia/src/test/java/org/apache/camel/component/platform/http/plugin/DefaultJolokiaPlatformHttpPluginTest.java
new file mode 100644
index 0000000000000..0eeaec4639a32
--- /dev/null
+++ b/components/camel-platform-http-jolokia/src/test/java/org/apache/camel/component/platform/http/plugin/DefaultJolokiaPlatformHttpPluginTest.java
@@ -0,0 +1,67 @@
+/*
+ * 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.plugin;
+
+import java.util.HashMap;
+import java.util.Optional;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.component.platform.http.spi.PlatformHttpPluginRegistry;
+import org.apache.camel.support.ResolverHelper;
+import org.jolokia.server.core.http.HttpRequestHandler;
+import org.json.simple.JSONAware;
+import org.json.simple.JSONObject;
+import org.json.simple.parser.JSONParser;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class DefaultJolokiaPlatformHttpPluginTest extends ContextTestSupport {
+
+ @Test
+ public void jolokiaPlatformHttpPluginContextTest() throws Exception {
+ PlatformHttpPluginRegistry registry = resolvePlatformHttpPluginRegistry();
+ Assertions.assertNotNull(registry);
+ DefaultJolokiaPlatformHttpPlugin plugin = (DefaultJolokiaPlatformHttpPlugin) registry
+ .resolvePluginById(DefaultJolokiaPlatformHttpPlugin.NAME).orElseThrow();
+ Assertions.assertNotNull(plugin);
+ HttpRequestHandler handler = plugin.getRequestHandler();
+
+ JSONAware json = handler.handleGetRequest("", "/", new HashMap<>());
+
+ JSONParser parser = new JSONParser();
+ JSONObject responseBody = (JSONObject) parser.parse(json.toJSONString());
+
+ 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("version", type);
+ assertEquals("2.0.1", agentVersion);
+ }
+
+ private PlatformHttpPluginRegistry resolvePlatformHttpPluginRegistry() {
+ Optional result = ResolverHelper.resolveService(
+ context,
+ PlatformHttpPluginRegistry.FACTORY,
+ PlatformHttpPluginRegistry.class);
+ return result.orElse(null);
+ }
+}
diff --git a/components/camel-platform-http-main/pom.xml b/components/camel-platform-http-main/pom.xml
index 0ee949ec6c4a7..c7ca3e970f198 100644
--- a/components/camel-platform-http-main/pom.xml
+++ b/components/camel-platform-http-main/pom.xml
@@ -44,13 +44,6 @@
camel-main
-
-
- org.jolokia
- jolokia-agent-jvm
- ${jolokia-version}
-
-
org.apache.camel
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 b93e12aff0d74..882e50ea706f9 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,7 +18,6 @@
import java.io.File;
import java.io.FileOutputStream;
-import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
@@ -30,6 +29,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Collectors;
@@ -58,7 +58,8 @@
import org.apache.camel.api.management.ManagedResource;
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.plugin.JolokiaPlatformHttpPlugin;
+import org.apache.camel.component.platform.http.spi.PlatformHttpPluginRegistry;
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;
@@ -68,6 +69,7 @@
import org.apache.camel.health.HealthCheckHelper;
import org.apache.camel.health.HealthCheckRegistry;
import org.apache.camel.spi.CamelEvent;
+import org.apache.camel.support.ResolverHelper;
import org.apache.camel.support.SimpleEventNotifierSupport;
import org.apache.camel.support.jsse.SSLContextParameters;
import org.apache.camel.support.service.ServiceHelper;
@@ -272,6 +274,18 @@ protected void doInit() throws Exception {
server = new VertxPlatformHttpServer(configuration);
camelContext.addService(server);
+
+ PlatformHttpPluginRegistry pluginRegistry
+ = getCamelContext().getCamelContextExtension().getContextPlugin(PlatformHttpPluginRegistry.class);
+ if (pluginRegistry == null && pluginsEnabled()) {
+ pluginRegistry = resolvePlatformHttpPluginRegistry();
+ pluginRegistry.setCamelContext(getCamelContext());
+ getCamelContext().getCamelContextExtension().addContextPlugin(PlatformHttpPluginRegistry.class, pluginRegistry);
+ }
+ }
+
+ private boolean pluginsEnabled() {
+ return jolokiaEnabled;
}
@Override
@@ -478,17 +492,22 @@ protected void setupJolokia() {
platformHttpComponent.addHttpEndpoint("/q/jolokia", null, null);
}
+ protected PlatformHttpPluginRegistry resolvePlatformHttpPluginRegistry() {
+ Optional result = ResolverHelper.resolveService(
+ getCamelContext(),
+ PlatformHttpPluginRegistry.FACTORY,
+ PlatformHttpPluginRegistry.class);
+ return result.orElse(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;
+ PlatformHttpPluginRegistry registry
+ = camelContext.getCamelContextExtension().getContextPlugin(PlatformHttpPluginRegistry.class);
+ JolokiaPlatformHttpPlugin jolokia
+ = (JolokiaPlatformHttpPlugin) registry.resolvePluginById(JolokiaPlatformHttpPlugin.NAME)
+ .orElseThrow(() -> new RuntimeException(
+ "JolokiaPlatformHttpPlugin not found. Please add camel-platform-http-jolokia dependency."));
+ return jolokia.getRequestHandler();
}
private Map getParams(MultiMap params) {
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
deleted file mode 100644
index 8da4c2b179d01..0000000000000
--- a/components/camel-platform-http-main/src/test/java/org/apache/camel/component/platform/http/main/MainHttpServerJolokiaTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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 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.1", agentVersion);
- }
-
-}
diff --git a/components/camel-platform-http/pom.xml b/components/camel-platform-http/pom.xml
index b1b5f3961f33a..5d567f0d69b0c 100644
--- a/components/camel-platform-http/pom.xml
+++ b/components/camel-platform-http/pom.xml
@@ -42,6 +42,13 @@
camel-util-json
+
+
+ org.jolokia
+ jolokia-agent-jvm
+ ${jolokia-version}
+
+
org.apache.camel
diff --git a/components/camel-platform-http/src/generated/resources/META-INF/services/org/apache/camel/component/platform/http/platform-http-plugin-registry b/components/camel-platform-http/src/generated/resources/META-INF/services/org/apache/camel/component/platform/http/platform-http-plugin-registry
new file mode 100644
index 0000000000000..a845295309dd9
--- /dev/null
+++ b/components/camel-platform-http/src/generated/resources/META-INF/services/org/apache/camel/component/platform/http/platform-http-plugin-registry
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.component.platform.http.PlatformHttpPluginRegistry
diff --git a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpPluginRegistry.java b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpPluginRegistry.java
new file mode 100644
index 0000000000000..115e2722f4f60
--- /dev/null
+++ b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/PlatformHttpPluginRegistry.java
@@ -0,0 +1,121 @@
+/*
+ * 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;
+
+import java.util.Comparator;
+import java.util.Optional;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelContextAware;
+import org.apache.camel.component.platform.http.spi.PlatformHttpPlugin;
+import org.apache.camel.spi.FactoryFinder;
+import org.apache.camel.spi.annotations.JdkService;
+import org.apache.camel.support.service.ServiceHelper;
+import org.apache.camel.support.service.ServiceSupport;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Default {@link org.apache.camel.component.platform.http.spi.PlatformHttpPluginRegistry}.
+ */
+@JdkService(org.apache.camel.component.platform.http.spi.PlatformHttpPluginRegistry.FACTORY)
+public class PlatformHttpPluginRegistry extends ServiceSupport
+ implements org.apache.camel.component.platform.http.spi.PlatformHttpPluginRegistry {
+
+ private static final String PLATFORM_HTTP_PLUGIN_FACTORY_PATH
+ = "META-INF/services/org/apache/camel/" + PLATFORM_HTTP_FACTORY_PATH + "plugin/";
+ private CamelContext camelContext;
+
+ private final Set plugins = new TreeSet<>(Comparator.comparing(PlatformHttpPlugin::getId));
+
+ private static final Logger LOG = LoggerFactory.getLogger(PlatformHttpPluginRegistry.class);
+
+ @Override
+ public Optional resolvePluginById(String id) {
+ PlatformHttpPlugin answer = plugins.stream().filter(plugin -> plugin.getId().equals(id)).findFirst()
+ .orElse(getCamelContext().getRegistry().findByTypeWithName(PlatformHttpPlugin.class).get(id));
+
+ if (answer == null) {
+ answer = resolvePluginWithFactoryFinderById(id);
+
+ }
+
+ if (answer != null) {
+ register(answer);
+ }
+
+ return Optional.ofNullable(answer);
+ }
+
+ @Override
+ public boolean register(PlatformHttpPlugin plugin) {
+ boolean result;
+
+ if (getPlugin(plugin.getId()).isPresent()) {
+ return false;
+ }
+
+ result = plugins.add(plugin);
+
+ if (result) {
+ CamelContextAware.trySetCamelContext(plugin, camelContext);
+ ServiceHelper.startService(plugin);
+ LOG.debug("platform-http-plugin with id {} successfully registered", plugin.getId());
+ }
+ return result;
+ }
+
+ private Optional getPlugin(String id) {
+ return plugins.stream()
+ .filter(r -> ObjectHelper.equal(r.getId(), id))
+ .findFirst();
+ }
+
+ @Override
+ public void setCamelContext(CamelContext camelContext) {
+ this.camelContext = camelContext;
+ }
+
+ @Override
+ public CamelContext getCamelContext() {
+ return camelContext;
+ }
+
+ private PlatformHttpPlugin resolvePluginWithFactoryFinderById(String id) {
+ PlatformHttpPlugin answer = null;
+ FactoryFinder factoryFinder
+ = getCamelContext().getCamelContextExtension().getFactoryFinder(PLATFORM_HTTP_PLUGIN_FACTORY_PATH);
+ Class> type = factoryFinder.findOptionalClass(id).orElse(null);
+
+ if (type != null) {
+ if (PlatformHttpPlugin.class.isAssignableFrom(type)) {
+ answer = (PlatformHttpPlugin) camelContext.getInjector().newInstance(type, false);
+ CamelContextAware.trySetCamelContext(answer, camelContext);
+ } else {
+ throw new IllegalArgumentException(
+ "Resolving platform-http-plugin: " + id
+ + " detected type conflict: Not a PlatformHttpPlugin implementation. Found: "
+ + type.getName());
+ }
+ }
+
+ return answer;
+ }
+}
diff --git a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/plugin/JolokiaPlatformHttpPlugin.java b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/plugin/JolokiaPlatformHttpPlugin.java
new file mode 100644
index 0000000000000..12e622fbfa485
--- /dev/null
+++ b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/plugin/JolokiaPlatformHttpPlugin.java
@@ -0,0 +1,30 @@
+/*
+ * 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.plugin;
+
+import org.apache.camel.component.platform.http.spi.PlatformHttpPlugin;
+import org.jolokia.server.core.http.HttpRequestHandler;
+
+/**
+ * camel-platform-http plugin.
+ */
+public interface JolokiaPlatformHttpPlugin extends PlatformHttpPlugin {
+
+ String NAME = "camel-platform-http-jolokia";
+
+ HttpRequestHandler getRequestHandler();
+}
diff --git a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/spi/PlatformHttpPlugin.java b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/spi/PlatformHttpPlugin.java
new file mode 100644
index 0000000000000..13e9dfd7a061f
--- /dev/null
+++ b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/spi/PlatformHttpPlugin.java
@@ -0,0 +1,32 @@
+/*
+ * 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.spi;
+
+import org.apache.camel.CamelContextAware;
+import org.apache.camel.StaticService;
+
+/**
+ * camel-platform-http plugin.
+ */
+public interface PlatformHttpPlugin extends StaticService, CamelContextAware {
+
+ /**
+ * The ID of this plugin.
+ */
+ String getId();
+
+}
diff --git a/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/spi/PlatformHttpPluginRegistry.java b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/spi/PlatformHttpPluginRegistry.java
new file mode 100644
index 0000000000000..e5742a87f1f25
--- /dev/null
+++ b/components/camel-platform-http/src/main/java/org/apache/camel/component/platform/http/spi/PlatformHttpPluginRegistry.java
@@ -0,0 +1,36 @@
+/*
+ * 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.spi;
+
+import java.util.Optional;
+
+import org.apache.camel.CamelContextAware;
+import org.apache.camel.StaticService;
+
+/**
+ * Factory to abstract the creation of the Plugin Registry for camel-platform-http.
+ */
+public interface PlatformHttpPluginRegistry extends CamelContextAware, StaticService {
+
+ String PLATFORM_HTTP_FACTORY_PATH = "component/platform/http/";
+
+ String FACTORY = PLATFORM_HTTP_FACTORY_PATH + "platform-http-plugin-registry";
+
+ Optional resolvePluginById(String id);
+
+ boolean register(PlatformHttpPlugin plugin);
+}
diff --git a/components/pom.xml b/components/pom.xml
index 0ec53589af550..f9c96cbe9ab89 100644
--- a/components/pom.xml
+++ b/components/pom.xml
@@ -234,8 +234,9 @@
camel-pg-replication-slot
camel-pgevent
camel-platform-http
- camel-platform-http-vertx
+ camel-platform-http-jolokia
camel-platform-http-main
+ camel-platform-http-vertx
camel-plc4x
camel-printer
camel-protobuf
diff --git a/parent/pom.xml b/parent/pom.xml
index f0ea047763e0b..acd84cf3bd0cd 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -1945,6 +1945,11 @@
camel-platform-http
${project.version}
+
+ org.apache.camel
+ camel-platform-http-jolokia
+ ${project.version}
+
org.apache.camel
camel-platform-http-main