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 faa1fcc148f CAMEL-21242: Adds camel-jolokia-starter (#1231)
faa1fcc148f is described below
commit faa1fcc148fac24f1cc3675fa42cb757e3f6d119
Author: Marco Carletti <[email protected]>
AuthorDate: Tue Sep 24 14:47:02 2024 +0200
CAMEL-21242: Adds camel-jolokia-starter (#1231)
---
components-starter/camel-jolokia-starter/pom.xml | 64 ++++++
.../camel-jolokia-starter/src/main/docs/.gitignore | 1 +
.../src/main/docs/jolokia.adoc | 108 ++++++++++
.../JolokiaComponentAutoConfiguration.java | 135 ++++++++++++
.../springboot/JolokiaComponentConfiguration.java | 232 +++++++++++++++++++++
.../springboot/restrictor/CamelRestrictor.java | 64 ++++++
.../src/main/resources/META-INF/LICENSE.txt | 203 ++++++++++++++++++
.../src/main/resources/META-INF/NOTICE.txt | 11 +
...rk.boot.autoconfigure.AutoConfiguration.imports | 18 ++
...onentAutoConfigurationCustomRestrictorTest.java | 53 +++++
...nentAutoConfigurationDefaultRestrictorTest.java | 51 +++++
...okiaComponentAutoConfigurationDisabledTest.java | 39 ++++
...omponentAutoConfigurationOnK8SDisabledTest.java | 39 ++++
...JolokiaComponentAutoConfigurationOnK8STest.java | 72 +++++++
...aComponentAutoConfigurationPrefersBeanTest.java | 60 ++++++
...nentAutoConfigurationPrefersPropertiesTest.java | 58 ++++++
.../JolokiaComponentAutoConfigurationTest.java | 93 +++++++++
...nentAutoConfigurationUsingConfigHolderTest.java | 37 ++++
...onentAutoConfigurationUsingCustomBeansTest.java | 73 +++++++
...AutoConfigurationUsingSystemPropertiesTest.java | 62 ++++++
...nentAutoConfigurationWithoutRestrictorTest.java | 47 +++++
.../springboot/JolokiaComponentTestBase.java | 35 ++++
.../jolokia/springboot/support/MyRestrictor.java | 32 +++
components-starter/pom.xml | 1 +
pom.xml | 1 +
tooling/camel-spring-boot-bom/pom.xml | 5 +
tooling/camel-spring-boot-dependencies/pom.xml | 5 +
27 files changed, 1599 insertions(+)
diff --git a/components-starter/camel-jolokia-starter/pom.xml
b/components-starter/camel-jolokia-starter/pom.xml
new file mode 100644
index 00000000000..dc82d37f64e
--- /dev/null
+++ b/components-starter/camel-jolokia-starter/pom.xml
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.springboot</groupId>
+ <artifactId>components-starter</artifactId>
+ <version>4.9.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>camel-jolokia-starter</artifactId>
+ <packaging>jar</packaging>
+ <name>Camel SB Starters :: Jolokia</name>
+ <description>Spring-Boot Starter for Jolokia server support</description>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter</artifactId>
+ <version>${spring-boot-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jolokia</groupId>
+ <artifactId>jolokia-support-spring</artifactId>
+ <version>${jolokia-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.springboot</groupId>
+ <artifactId>camel-management-starter</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.springboot</groupId>
+ <artifactId>camel-xml-io-dsl-starter</artifactId>
+ </dependency>
+ <!-- Test dependencies -->
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <version>${spring-boot-version}</version>
+ <scope>test</scope>
+ </dependency>
+ <!--START OF GENERATED CODE-->
+ <dependency>
+ <groupId>org.apache.camel.springboot</groupId>
+ <artifactId>camel-core-starter</artifactId>
+ </dependency>
+ <!--END OF GENERATED CODE-->
+ </dependencies>
+</project>
diff --git a/components-starter/camel-jolokia-starter/src/main/docs/.gitignore
b/components-starter/camel-jolokia-starter/src/main/docs/.gitignore
new file mode 100644
index 00000000000..4f9a65d1033
--- /dev/null
+++ b/components-starter/camel-jolokia-starter/src/main/docs/.gitignore
@@ -0,0 +1 @@
+jolokia.json
diff --git
a/components-starter/camel-jolokia-starter/src/main/docs/jolokia.adoc
b/components-starter/camel-jolokia-starter/src/main/docs/jolokia.adoc
new file mode 100644
index 00000000000..49f1c2d9435
--- /dev/null
+++ b/components-starter/camel-jolokia-starter/src/main/docs/jolokia.adoc
@@ -0,0 +1,108 @@
+= Jolokia Starter
+//Manually maintained attributes
+:artifactid: camel-jolokia-starter
+:shortname: jolokia
+:camel-spring-boot-name: jolokia
+
+Integrates Jolokia agent configuration in Spring Boot,
+it wraps the https://jolokia.org/reference/html/manual/spring.html[Spring
Support] adding
+default configurations to let the application working out-of-the-box without
manually declaring Jolokia servers.
+
+This starter can be considered an alternative to the
https://jolokia.org/reference/html/manual/agents.html[Jolokia JVM agent].
+
+To start the Jolokia endpoint it is enough to add the dependency:
+
+[source,xml]
+----
+<dependency>
+ <groupId>org.apache.camel.springboot</groupId>
+ <artifactId>camel-jolokia-starter</artifactId>
+</dependency>
+----
+
+This will expose the Jolokia endpoint at `http://0.0.0.0:8778/jolokia/` ,
+the agent can be configured according to the
https://jolokia.org/reference/html/manual/spring.html#_support_for_spring_framework_in_jolokia[Jolokia
Spring support page]
+using the property prefix `camel.component.jolokia` i.e. it is possible to
configure something like
+`camel.component.jolokia.lookup-config=true`.
+
+Moreover, it is possible to configure the Jolokia server accessing to the
configuration map via properties
+according to
https://jolokia.org/reference/html/manual/agents.html#jvm-agent-installation[Jolokia
agent configuration]
+using `camel.component.jolokia.server-config` map configuration,
+i.e. `camel.component.jolokia.server-config.port=8779` or
`camel.component.jolokia.server-config.authMode=jaas`
+
+To avoid to expose all the JMX MBeans (see
https://jolokia.org/reference/html/manual/security.html[Security]
considerations),
+it is provided a default Jolokia
https://jolokia.org/reference/html/manual/security.html#security-restrictor[Restrictor]
+that allows only Camel related data and some basic information from java.
+Everytime it is possible to avoid to use the restrictor with the property
`camel.component.jolokia.use-camel-restrictor=false`
+or to use your own custom one with the property
`camel.component.jolokia.server-config.restrictorClass=org.example.MyRestrictor`
+
+An example to extend the provided restrictor can be
+
+[source,java]
+----
+public class MyRestrictor extends CamelRestrictor {
+
+ //getDefaultDomains() contains default domains, if you want to add some
domain to the existing list
+ @Override
+ protected List<String> getAllowedDomains() {
+ final List<String> newDomains = new
ArrayList<>(getDefaultDomains());
+ newDomains.add("my.domain");
+ return newDomains;
+ }
+}
+----
+
+The starter creates a default configuration according to the provided
properties,
+that covers all the configuration for the Jolokia agent/server but if you want
+to use your custom `SpringJolokiaConfigHolder` implementation, it is possible
declaring
+in the Spring context a Bean named `camelConfigHolder`
+
+[source,java]
+----
+ @Bean("camelConfigHolder")
+ public SpringJolokiaConfigHolder myConfigHolder() {
+ final SpringJolokiaConfigHolder myConfig = new
SpringJolokiaConfigHolder();
+ myConfig.setConfig(Map.of("threadNr", "5", "executor", "fixed"));
+ return myConfig;
+ }
+----
+In this case the executor configuration will be taken from the custom Bean if
the same properties
+are not defined in the application.properties. This behaviour is also
configurable with the property
+`camel.component.jolokia.config-from-properties-first=false`, it means that
the configuration,
+in case the key is present in both application.properties and Bean
implementation, uses the one from Bean.
+If the keys from properties and beans are not overridden each other, the
simple merge will be applied.
+Anyway the configuration properties allow to cover all the configurable aspect
of the Jolokia server.
+
+There is a log configuration also provided in the starter that uses the
`slf4j` implementation.
+It is possible to change this configuration providing a Bean named
`camelLogHandlerHolder`
+
+[source,java]
+----
+ @Bean
+ @ConditionalOnMissingBean(name = "camelLogHandlerHolder")
+ public SpringJolokiaLogHandlerHolder myLogHandlerHolder() {
+ final SpringJolokiaLogHandlerHolder stdoutHandlerHolder = new
SpringJolokiaLogHandlerHolder();
+ stdoutHandlerHolder.setType("stdout");
+ return stdoutHandlerHolder;
+ }
+----
+The category for the Camel Spring Boot starter is
`org.apache.camel.component.jolokia`
+while it is possible to configure level of the core Jolokia server with
`org.jolokia`
+
+example in application.properties
+[source,properties]
+----
+logging.level.org.apache.camel.component.jolokia = TRACE
+logging.level.org.jolokia = TRACE
+----
+
+The starter also provides some default configurations in case of the
environment is a
+Kubernetes cluster. The starter checks the existence of a specific file to use
as
+certification authority
(`/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt`) and, if this
file exists, it initializes the server using
+TLS protocol and client authentication. So the endpoint become
`https://0.0.0.0:8778/jolokia/`
+It is possible to avoid this behaviour with the property
`camel.component.jolokia.kubernetes-discover=false`
+
+The wrapped library `Jolokia Spring Support` provides the integration with
+the Spring Boot Actuator as per
https://jolokia.org/reference/html/manual/spring.html#_registering_agent_servlet_under_spring_boot_actuator[configuration]
+where it is possible to retrieve information about Jolokia server.
+As any other actuator endpoint, it is possible to be excluded or disabled.
diff --git
a/components-starter/camel-jolokia-starter/src/main/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfiguration.java
b/components-starter/camel-jolokia-starter/src/main/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfiguration.java
new file mode 100644
index 00000000000..d7b2a5aba14
--- /dev/null
+++
b/components-starter/camel-jolokia-starter/src/main/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfiguration.java
@@ -0,0 +1,135 @@
+/*
+ * 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.jolokia.springboot;
+
+import org.jolokia.server.core.config.ConfigKey;
+import org.jolokia.support.spring.SpringJolokiaAgent;
+import org.jolokia.support.spring.SpringJolokiaConfigHolder;
+import org.jolokia.support.spring.SpringJolokiaLogHandlerHolder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import
org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.HashMap;
+import java.util.Map;
+
+@Configuration(proxyBeanMethods = false)
+@ConditionalOnMissingBean(type =
"org.jolokia.support.spring.SpringJolokiaAgent")
+@EnableConfigurationProperties(JolokiaComponentConfiguration.class)
+@ConditionalOnProperty(name = "camel.component.jolokia.enabled", havingValue =
"true", matchIfMissing = true)
+public class JolokiaComponentAutoConfiguration {
+
+ private static final Logger LOG =
LoggerFactory.getLogger(JolokiaComponentAutoConfiguration.class);
+
+ protected static final String DEFAULT_CA_ON_K8S =
"/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt";
+
+ @Autowired
+ private JolokiaComponentConfiguration configuration;
+
+ @Bean
+ public SpringJolokiaAgent jolokia(final SpringJolokiaConfigHolder
camelConfigHolder,
+ final SpringJolokiaLogHandlerHolder
camelLogHandlerHolder) {
+ LOG.debug("creating agent instance");
+
+ //in case of custom camelConfigHolder, the properties are merged
+ final Map<String, String> mergedMap =
mergeConfig(configuration.getServerConfig(), camelConfigHolder.getConfig());
+ camelConfigHolder.setConfig(mergedMap);
+ configuration.setServerConfig(mergedMap);
+
+ final SpringJolokiaAgent agent = new SpringJolokiaAgent();
+ agent.setLookupConfig(configuration.isLookupConfig());
+ agent.setLookupServices(configuration.isLookupServices());
+
agent.setSystemPropertiesMode(configuration.getSystemPropertiesMode());
+
agent.setExposeApplicationContext(configuration.isExposeApplicationContext());
+ agent.setConfig(camelConfigHolder);
+ agent.setLogHandler(camelLogHandlerHolder);
+ printConfiguration();
+ return agent;
+ }
+
+ @Bean
+ @ConditionalOnMissingBean(name = "camelLogHandlerHolder")
+ public SpringJolokiaLogHandlerHolder camelLogHandlerHolder() {
+ LOG.debug("jolokia logging using slf4j");
+ final SpringJolokiaLogHandlerHolder logHandlerHolder = new
SpringJolokiaLogHandlerHolder();
+ logHandlerHolder.setType("slf4j");
+ return logHandlerHolder;
+ }
+
+ @Bean
+ @ConditionalOnMissingBean(name = "camelConfigHolder")
+ public SpringJolokiaConfigHolder camelConfigHolder() {
+ LOG.debug("jolokia configuration from properties");
+ final SpringJolokiaConfigHolder springJolokiaConfigHolder = new
SpringJolokiaConfigHolder();
+ setDefaultConfigValue("host", "0.0.0.0");
+ setDefaultConfigValue("autoStart", "true");
+ if (configuration.isUseCamelRestrictor()
+ &&
!configuration.getServerConfig().containsKey(ConfigKey.RESTRICTOR_CLASS.getKeyValue()))
{
+
setDefaultConfigValue(ConfigKey.RESTRICTOR_CLASS.getKeyValue(),
+
"org.apache.camel.component.jolokia.springboot.restrictor.CamelRestrictor");
+ }
+ if (configuration.isKubernetesDiscover()) {
+ LOG.debug("trying to discover k8s environment");
+ final String caCert =
configuration.isKubernetesUseDefaultCa() ? DEFAULT_CA_ON_K8S
+ :
configuration.getServerConfig().getOrDefault("caCert", DEFAULT_CA_ON_K8S);
+ if (Files.exists(Path.of(caCert))) {
+ setDefaultConfigValue("protocol", "https");
+
setDefaultConfigValue("useSslClientAuthentication", "true");
+ setDefaultConfigValue("caCert", caCert);
+ } else {
+ LOG.debug("kubernetesDiscover is enabled but
the file {} does not exist, no additional properties will be set", caCert);
+ }
+ }
+
springJolokiaConfigHolder.setConfig(configuration.getServerConfig());
+ return springJolokiaConfigHolder;
+ }
+
+ private void setDefaultConfigValue(String key, String defaultValue) {
+ final String configValue =
configuration.getServerConfig().getOrDefault(key, defaultValue);
+ LOG.debug("jolokia config set {} = {}", key, configValue);
+ configuration.getServerConfig().put(key, configValue);
+ }
+
+ private void printConfiguration() {
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("jolokia agent configuration: {}",
configuration);
+ }
+ }
+
+ private Map<String, String> mergeConfig(Map<String, String> fromConfig,
Map<String, String> fromBean) {
+ //in case no custom bean, it is the same object
+ if (fromConfig.equals(fromBean)) {
+ return fromConfig;
+ }
+ final Map<String, String> mergedMap = new HashMap<>(fromConfig);
+ fromBean.forEach((beanKey, beanVal) -> {
+ if (configuration.isConfigFromPropertiesFirst()) {
+ mergedMap.put(beanKey,
fromConfig.getOrDefault(beanKey, beanVal));
+ } else {
+ mergedMap.put(beanKey, beanVal);
+ }
+ });
+ return mergedMap;
+ }
+}
diff --git
a/components-starter/camel-jolokia-starter/src/main/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentConfiguration.java
b/components-starter/camel-jolokia-starter/src/main/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentConfiguration.java
new file mode 100644
index 00000000000..c43af2e055f
--- /dev/null
+++
b/components-starter/camel-jolokia-starter/src/main/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentConfiguration.java
@@ -0,0 +1,232 @@
+/*
+ * 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.jolokia.springboot;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.StringJoiner;
+
+@ConfigurationProperties(prefix = "camel.component.jolokia")
+public class JolokiaComponentConfiguration {
+
+ /**
+ *
+ * Enable the component, default true.
+ *
+ */
+ private boolean enabled = true;
+
+ /**
+ *
+ * If set to true, Spring’s application context is searched for
additional beans of org.jolokia.support.spring.SpringJolokiaConfigHolder class
+ * that are used to configure the agent, default false.
+ *
+ * @see <a
href="https://jolokia.org/reference/html/manual/spring.html">Support for Spring
Framework in Jolokia</a>
+ *
+ */
+ private boolean lookupConfig = false;
+
+ /**
+ *
+ * If set to true, Spring’s application context is searched for
additional beans of org.jolokia.server.core.service.api.JolokiaService.
+ * These beans are added to Jolokia internal context as services used
by the Agent, default false.
+ *
+ * @see <a
href="https://jolokia.org/reference/html/manual/spring.html">Support for Spring
Framework in Jolokia</a>
+ *
+ */
+ private boolean lookupServices = false;
+
+ /**
+ *
+ * Specifies how system properties with jolokia. prefix (the prefix is
then stripped) affect Jolokia Agent configuration, default 'never'.
+ * There are three modes available:
+ *
+ * <ul>
+ * <li>never - No lookup is done on system properties as all. This is
the default mode.</li>
+ *
+ * <li>fallback - System properties with a prefix jolokia. are used as
fallback configuration values if not specified locally in the Spring
application context.
+ * E.g. jolokia.port=8888 will change the port on which the agent is
listening to 8888 if the port is not explicitly specified in the
configuration.</li>
+ *
+ * <li>override - System properties with a prefix jolokia. are used as
configuration values even if they are specified locally in the Spring
application context.
+ * E.g. jolokia.port=8888 will change the port on which the agent is
listening to 8888 in any case.</li>
+ * </ul>
+ * @see <a
href="https://jolokia.org/reference/html/manual/spring.html">Support for Spring
Framework in Jolokia</a>
+ *
+ */
+ private String systemPropertiesMode = "never";
+
+ /**
+ *
+ * If set to true, additional
org.jolokia.support.spring.backend.SpringRequestHandler is added to the agent,
+ * so we can invoke Spring bean operations using Jolokia protocol,
default false.
+ *
+ * @see <a
href="https://jolokia.org/reference/html/manual/spring.html">Support for Spring
Framework in Jolokia</a>
+ *
+ */
+ private boolean exposeApplicationContext = false;
+
+ /**
+ *
+ * Configuration for the exposed endpoint.
+ * Example:
+ * <pre>
+ * camel.component.jolokia.serverConfig.discoveryEnabled=true
+ * </pre>
+ * @see <a
href="https://jolokia.org/reference/html/manual/agents.html#jvm-agent">JVM
agent configuration options</a>
+ *
+ */
+ private Map<String, String> serverConfig = new HashMap<>();
+
+ /**
+ *
+ * To set default properties to make the jolokia enpoint work on
k8s/OCP, default true.
+ *
+ * It sets:
+ * <ul>
+ * <li>protocol = https</li>
+ * <li>caCert =
/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt</li>
+ * <li>useSslClientAuthentication = true</li>
+ * </ul>
+ */
+ private boolean kubernetesDiscover = true;
+
+ /**
+ *
+ * To prefer the default CA file, default true.
+ * <pre>
+ * /var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt
+ * </pre>
+ */
+ private boolean kubernetesUseDefaultCa = true;
+
+ /**
+ *
+ * All operations on MBeans are allowed by default, the Camel
restrictor allows only operations on Camel domain, default true.
+ * If key 'restrictorClass' in serverConfig has been provided, this
property will be ignorated.
+ * <pre>
+ *
org.apache.camel.component.jolokia.springboot.restrictor.CamelRestrictor
+ * </pre>
+ */
+ private boolean useCamelRestrictor = true;
+
+ /**
+ *
+ * In case of custom bean configuration (it is necessary to provide a
bean named 'camelConfigHolder' of type SpringJolokiaConfigHolder)
+ * containing the same keys provided by the configuration
(application.properties),
+ * it prefers values from configuration on values from bean, default
true.
+ *
+ */
+ private boolean configFromPropertiesFirst = true;
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(final boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public boolean isLookupConfig() {
+ return lookupConfig;
+ }
+
+ public void setLookupConfig(final boolean lookupConfig) {
+ this.lookupConfig = lookupConfig;
+ }
+
+ public boolean isLookupServices() {
+ return lookupServices;
+ }
+
+ public void setLookupServices(final boolean lookupServices) {
+ this.lookupServices = lookupServices;
+ }
+
+ public String getSystemPropertiesMode() {
+ return systemPropertiesMode;
+ }
+
+ public void setSystemPropertiesMode(final String systemPropertiesMode) {
+ this.systemPropertiesMode = systemPropertiesMode;
+ }
+
+ public boolean isExposeApplicationContext() {
+ return exposeApplicationContext;
+ }
+
+ public void setExposeApplicationContext(final boolean
exposeApplicationContext) {
+ this.exposeApplicationContext = exposeApplicationContext;
+ }
+
+ public Map<String, String> getServerConfig() {
+ return serverConfig;
+ }
+
+ public void setServerConfig(final Map<String, String> serverConfig) {
+ this.serverConfig = serverConfig;
+ }
+
+ public boolean isKubernetesDiscover() {
+ return kubernetesDiscover;
+ }
+
+ public void setKubernetesDiscover(final boolean kubernetesDiscover) {
+ this.kubernetesDiscover = kubernetesDiscover;
+ }
+
+ public boolean isKubernetesUseDefaultCa() {
+ return kubernetesUseDefaultCa;
+ }
+
+ public void setKubernetesUseDefaultCa(final boolean
kubernetesUseDefaultCa) {
+ this.kubernetesUseDefaultCa = kubernetesUseDefaultCa;
+ }
+
+ public boolean isUseCamelRestrictor() {
+ return useCamelRestrictor;
+ }
+
+ public void setUseCamelRestrictor(final boolean useCamelRestrictor) {
+ this.useCamelRestrictor = useCamelRestrictor;
+ }
+
+ public boolean isConfigFromPropertiesFirst() {
+ return configFromPropertiesFirst;
+ }
+
+ public void setConfigFromPropertiesFirst(final boolean
configFromPropertiesFirst) {
+ this.configFromPropertiesFirst = configFromPropertiesFirst;
+ }
+
+ @Override
+ public String toString() {
+ return new StringJoiner(", ",
JolokiaComponentConfiguration.class.getSimpleName() + "[", "]")
+ .add("enabled=" + enabled)
+ .add("lookupConfig=" + lookupConfig)
+ .add("lookupServices=" + lookupServices)
+ .add("systemPropertiesMode='" +
systemPropertiesMode + "'")
+ .add("exposeApplicationContext=" +
exposeApplicationContext)
+ .add("serverConfig=" + serverConfig)
+ .add("kubernetesDiscover=" + kubernetesDiscover)
+ .add("kubernetesUseDefaultCa=" +
kubernetesUseDefaultCa)
+ .add("useCamelRestrictor=" + useCamelRestrictor)
+ .add("configFromPropertiesFirst=" +
configFromPropertiesFirst)
+ .toString();
+ }
+}
diff --git
a/components-starter/camel-jolokia-starter/src/main/java/org/apache/camel/component/jolokia/springboot/restrictor/CamelRestrictor.java
b/components-starter/camel-jolokia-starter/src/main/java/org/apache/camel/component/jolokia/springboot/restrictor/CamelRestrictor.java
new file mode 100644
index 00000000000..62d2fea82c9
--- /dev/null
+++
b/components-starter/camel-jolokia-starter/src/main/java/org/apache/camel/component/jolokia/springboot/restrictor/CamelRestrictor.java
@@ -0,0 +1,64 @@
+/*
+ * 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.jolokia.springboot.restrictor;
+
+import org.jolokia.server.core.restrictor.AllowAllRestrictor;
+
+import javax.management.ObjectName;
+
+import java.util.List;
+import java.util.function.Function;
+
+public class CamelRestrictor extends AllowAllRestrictor {
+
+ private final List<String> allowedDomains = List.of("org.apache.camel",
"java.lang", "java.nio", "jboss.threads");
+
+ private Function<ObjectName, Boolean> objectNameEvaluator =
+ objectName ->
this.getAllowedDomains().contains(objectName.getDomain());
+
+ @Override
+ public boolean isAttributeReadAllowed(ObjectName pName, String
pAttribute) {
+ return objectNameEvaluator.apply(pName);
+ }
+
+ @Override
+ public boolean isAttributeWriteAllowed(ObjectName pName, String
pAttribute) {
+ return objectNameEvaluator.apply(pName);
+ }
+
+ @Override
+ public boolean isOperationAllowed(ObjectName pName, String pOperation) {
+ return objectNameEvaluator.apply(pName);
+ }
+
+ @Override
+ public boolean isObjectNameHidden(ObjectName name) {
+ return !objectNameEvaluator.apply(name);
+ }
+
+ /**
+ * Provides the list of allowed domains from JMX.
+ * @return List of String, the list of the allowed domains.
+ */
+ protected List<String> getAllowedDomains() {
+ return allowedDomains;
+ }
+
+ protected final List<String> getDefaultDomains() {
+ return allowedDomains;
+ }
+}
diff --git
a/components-starter/camel-jolokia-starter/src/main/resources/META-INF/LICENSE.txt
b/components-starter/camel-jolokia-starter/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 00000000000..6b0b1270ff0
--- /dev/null
+++
b/components-starter/camel-jolokia-starter/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,203 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
+
diff --git
a/components-starter/camel-jolokia-starter/src/main/resources/META-INF/NOTICE.txt
b/components-starter/camel-jolokia-starter/src/main/resources/META-INF/NOTICE.txt
new file mode 100644
index 00000000000..2e215bf2e6b
--- /dev/null
+++
b/components-starter/camel-jolokia-starter/src/main/resources/META-INF/NOTICE.txt
@@ -0,0 +1,11 @@
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for the Apache Camel distribution. ==
+ =========================================================================
+
+ This product includes software developed by
+ The Apache Software Foundation (http://www.apache.org/).
+
+ Please read the different LICENSE files present in the licenses directory of
+ this distribution.
diff --git
a/components-starter/camel-jolokia-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
b/components-starter/camel-jolokia-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
new file mode 100644
index 00000000000..18eeed6017c
--- /dev/null
+++
b/components-starter/camel-jolokia-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -0,0 +1,18 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+org.apache.camel.component.jolokia.springboot.JolokiaComponentAutoConfiguration
diff --git
a/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationCustomRestrictorTest.java
b/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationCustomRestrictorTest.java
new file mode 100644
index 00000000000..d1c700158ce
--- /dev/null
+++
b/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationCustomRestrictorTest.java
@@ -0,0 +1,53 @@
+/*
+ * 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.jolokia.springboot;
+
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+import org.assertj.core.api.Assertions;
+import org.assertj.core.api.InstanceOfAssertFactories;
+import org.jolokia.server.core.config.ConfigKey;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest(classes = {CamelAutoConfiguration.class,
+ JolokiaComponentAutoConfiguration.class},
+ properties = {"camel.component.jolokia.serverConfig.port=0",
+
"camel.component.jolokia.serverConfig.restrictorClass=org.apache.camel.component.jolokia.springboot.support.MyRestrictor"})
+public class JolokiaComponentAutoConfigurationCustomRestrictorTest extends
JolokiaComponentTestBase {
+
+ @Test
+ void checkConfigurationTest() {
+
+ Assertions.assertThat(agent)
+ .describedAs("check the configHolder
restrictorClass property")
+ .extracting("configHolder").isNotNull()
+ .extracting("config")
+
.asInstanceOf(InstanceOfAssertFactories.map(String.class, String.class))
+
.containsEntry(ConfigKey.RESTRICTOR_CLASS.getKeyValue(),
+
"org.apache.camel.component.jolokia.springboot.support.MyRestrictor");
+
+
Assertions.assertThat(agent.getServerConfig().getJolokiaConfig().containsKey(ConfigKey.RESTRICTOR_CLASS))
+ .as("check the jolokia config")
+ .isTrue();
+
+
Assertions.assertThat(agent.getServerConfig().getJolokiaConfig().getConfig(ConfigKey.RESTRICTOR_CLASS))
+ .as("check the jolokia config")
+
.isEqualTo("org.apache.camel.component.jolokia.springboot.support.MyRestrictor");
+ }
+}
diff --git
a/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationDefaultRestrictorTest.java
b/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationDefaultRestrictorTest.java
new file mode 100644
index 00000000000..a526a795b2b
--- /dev/null
+++
b/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationDefaultRestrictorTest.java
@@ -0,0 +1,51 @@
+/*
+ * 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.jolokia.springboot;
+
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+import org.assertj.core.api.Assertions;
+import org.assertj.core.api.InstanceOfAssertFactories;
+import org.jolokia.server.core.config.ConfigKey;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest(classes = {CamelAutoConfiguration.class,
JolokiaComponentAutoConfiguration.class},
+ properties = "camel.component.jolokia.serverConfig.port=0")
+public class JolokiaComponentAutoConfigurationDefaultRestrictorTest extends
JolokiaComponentTestBase {
+
+ @Test
+ void checkConfigurationTest() {
+
+ Assertions.assertThat(agent)
+ .describedAs("check the configHolder
restrictorClass property")
+ .extracting("configHolder").isNotNull()
+ .extracting("config")
+
.asInstanceOf(InstanceOfAssertFactories.map(String.class, String.class))
+
.containsEntry(ConfigKey.RESTRICTOR_CLASS.getKeyValue(),
+
"org.apache.camel.component.jolokia.springboot.restrictor.CamelRestrictor");
+
+
Assertions.assertThat(agent.getServerConfig().getJolokiaConfig().containsKey(ConfigKey.RESTRICTOR_CLASS))
+ .as("check the jolokia config")
+ .isTrue();
+
+
Assertions.assertThat(agent.getServerConfig().getJolokiaConfig().getConfig(ConfigKey.RESTRICTOR_CLASS))
+ .as("check the jolokia config")
+
.isEqualTo("org.apache.camel.component.jolokia.springboot.restrictor.CamelRestrictor");
+ }
+}
diff --git
a/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationDisabledTest.java
b/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationDisabledTest.java
new file mode 100644
index 00000000000..815030cbd48
--- /dev/null
+++
b/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationDisabledTest.java
@@ -0,0 +1,39 @@
+/*
+ * 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.jolokia.springboot;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+import org.jolokia.support.spring.SpringJolokiaAgent;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest(classes = {CamelAutoConfiguration.class,
JolokiaComponentAutoConfiguration.class}, properties =
"camel.component.jolokia.enabled=false")
+public class JolokiaComponentAutoConfigurationDisabledTest {
+
+ @Autowired(required = false)
+ protected SpringJolokiaAgent agent;
+
+ @Test
+ void agentIsNotLoadedTest() {
+ assertThat(agent).isNull();
+ }
+}
diff --git
a/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationOnK8SDisabledTest.java
b/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationOnK8SDisabledTest.java
new file mode 100644
index 00000000000..624e7056d84
--- /dev/null
+++
b/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationOnK8SDisabledTest.java
@@ -0,0 +1,39 @@
+/*
+ * 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.jolokia.springboot;
+
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+import org.assertj.core.api.Assertions;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest(classes = {CamelAutoConfiguration.class,
JolokiaComponentAutoConfiguration.class},
+ properties =
{"camel.component.jolokia.kubernetesDiscover=false",
"camel.component.jolokia.serverConfig.port=0"})
+public class JolokiaComponentAutoConfigurationOnK8SDisabledTest extends
JolokiaComponentTestBase {
+
+ @Test
+ void httpConfigurationTest() {
+
Assertions.assertThat(agent.getServerConfig().getCaCert()).as("check caCert is
not set")
+ .isNull();
+
Assertions.assertThat(agent.getServerConfig().getProtocol()).as("check protocol
configuration")
+ .isEqualTo("http");
+
Assertions.assertThat(agent.getServerConfig().useSslClientAuthentication()).as("check
useSslClientAuthentication ssl configuration")
+ .isFalse();
+ }
+}
diff --git
a/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationOnK8STest.java
b/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationOnK8STest.java
new file mode 100644
index 00000000000..1b0c6798f68
--- /dev/null
+++
b/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationOnK8STest.java
@@ -0,0 +1,72 @@
+/*
+ * 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.jolokia.springboot;
+
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+import org.assertj.core.api.Assertions;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.DynamicPropertyRegistry;
+import org.springframework.test.context.DynamicPropertySource;
+import org.springframework.test.util.TestSocketUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+@SpringBootTest(classes = {CamelAutoConfiguration.class,
JolokiaComponentAutoConfiguration.class},
+ properties =
"camel.component.jolokia.kubernetesUseDefaultCa=false")
+public class JolokiaComponentAutoConfigurationOnK8STest extends
JolokiaComponentTestBase {
+
+ @DynamicPropertySource
+ static void customProperties(DynamicPropertyRegistry registry) {
+ registry.add("camel.component.jolokia.serverConfig.caCert",
+ () -> {
+ try {
+ final Path caPath =
Files.createTempFile("csb", ".ca");
+ caPath.toFile().deleteOnExit();
+ return
caPath.toAbsolutePath().toString();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ });
+ registry.add("camel.component.jolokia.serverConfig.port",
+ () ->
String.valueOf(TestSocketUtils.findAvailableTcpPort()));
+ }
+
+ @Test
+ void sslConfigurationTest() {
+
Assertions.assertThat(agent.getServerConfig().getCaCert()).as("check caCert ssl
configuration")
+ .isNotBlank()
+
.startsWith(String.format("%s%scsb", System.getProperty("java.io.tmpdir"),
File.separator))
+ .endsWith(".ca");
+
Assertions.assertThat(agent.getServerConfig().getProtocol()).as("check ssl
protocol configuration")
+ .isEqualTo("https");
+
Assertions.assertThat(agent.getServerConfig().useSslClientAuthentication()).as("check
useSslClientAuthentication ssl configuration")
+ .isTrue();
+ Assertions.assertThat(agent).as("check default configuration")
+ .hasFieldOrProperty("config").isNotNull()
+ .extracting("config")
+ .hasFieldOrPropertyWithValue("protocol",
"https")
+ .hasFieldOrPropertyWithValue("context",
"/jolokia/")
+
.hasFieldOrPropertyWithValue("useSslClientAuthentication", true)
+ .hasFieldOrProperty("caCert").isNotNull();
+ }
+}
diff --git
a/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationPrefersBeanTest.java
b/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationPrefersBeanTest.java
new file mode 100644
index 00000000000..17740cdb97e
--- /dev/null
+++
b/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationPrefersBeanTest.java
@@ -0,0 +1,60 @@
+/*
+ * 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.jolokia.springboot;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+import org.jolokia.support.spring.SpringJolokiaConfigHolder;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import java.util.Map;
+
+@SpringBootTest(classes =
{JolokiaComponentAutoConfigurationPrefersBeanTest.TestConfiguration.class,
CamelAutoConfiguration.class, JolokiaComponentAutoConfiguration.class},
+ properties = {"camel.component.jolokia.serverConfig.port=8778",
+
"camel.component.jolokia.configFromPropertiesFirst=false",
+
"logging.level.org.apache.camel.component.jolokia=TRACE"})
+public class JolokiaComponentAutoConfigurationPrefersBeanTest extends
JolokiaComponentTestBase {
+
+ @Test
+ void checkPortIsRandomTest() {
+ assertThat(agent.getAddress().getPort())
+ .describedAs("check the value from custom bean
overrides the properties")
+ .isNotZero()
+ .isNotEqualTo(8778);
+ }
+
+ // *************************************
+ // Config
+ // *************************************
+
+ @Configuration
+ public static class TestConfiguration {
+
+ @Bean("camelConfigHolder")
+ public SpringJolokiaConfigHolder configHolder() {
+ final SpringJolokiaConfigHolder myConfig = new
SpringJolokiaConfigHolder();
+ myConfig.setConfig(Map.of("port", "0"));
+ return myConfig;
+ }
+ }
+}
diff --git
a/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationPrefersPropertiesTest.java
b/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationPrefersPropertiesTest.java
new file mode 100644
index 00000000000..313a1df70bc
--- /dev/null
+++
b/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationPrefersPropertiesTest.java
@@ -0,0 +1,58 @@
+/*
+ * 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.jolokia.springboot;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+import org.jolokia.support.spring.SpringJolokiaConfigHolder;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import java.util.Map;
+
+@SpringBootTest(classes =
{JolokiaComponentAutoConfigurationPrefersPropertiesTest.TestConfiguration.class,
CamelAutoConfiguration.class, JolokiaComponentAutoConfiguration.class},
+ properties = {"camel.component.jolokia.serverConfig.port=0",
"logging.level.org.apache.camel.component.jolokia=TRACE"})
+public class JolokiaComponentAutoConfigurationPrefersPropertiesTest extends
JolokiaComponentTestBase {
+
+ @Test
+ void checkPortIsRandomTest() {
+ assertThat(agent.getAddress().getPort())
+ .describedAs("check the value from custom bean
does not override the properties")
+ .isNotZero()
+ .isNotEqualTo(8778);
+ }
+
+ // *************************************
+ // Config
+ // *************************************
+
+ @Configuration
+ public static class TestConfiguration {
+
+ @Bean("camelConfigHolder")
+ public SpringJolokiaConfigHolder configHolder() {
+ final SpringJolokiaConfigHolder myConfig = new
SpringJolokiaConfigHolder();
+ myConfig.setConfig(Map.of("port", "8778"));
+ return myConfig;
+ }
+ }
+}
diff --git
a/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationTest.java
b/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationTest.java
new file mode 100644
index 00000000000..6504a2ee11e
--- /dev/null
+++
b/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationTest.java
@@ -0,0 +1,93 @@
+/*
+ * 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.jolokia.springboot;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+
+import
org.apache.camel.component.jolokia.springboot.restrictor.CamelRestrictor;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+import org.assertj.core.api.Assertions;
+import org.assertj.core.api.InstanceOfAssertFactories;
+import org.jolokia.support.spring.SystemPropertyMode;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.ApplicationContext;
+
+import java.net.Socket;
+
+@SpringBootTest(classes = {CamelAutoConfiguration.class,
JolokiaComponentAutoConfiguration.class},
+ properties = "camel.component.jolokia.serverConfig.port=0")
+public class JolokiaComponentAutoConfigurationTest extends
JolokiaComponentTestBase {
+
+ @Autowired
+ ApplicationContext context;
+
+ @Test
+ void agentIsLoadedTest() {
+ //just check the agent
+ }
+
+ @Test
+ void agentIsStartedTest() {
+ assertThat(agent.getAddress()).isNotNull();
+ assertThat(agent.getAddress().getPort()).isGreaterThan(0);
+ Assertions.assertThatCode(() -> new
Socket().connect(agent.getAddress()))
+ .as("check connection to %s:%s",
agent.getAddress().getHostName(), agent.getAddress().getPort())
+ .doesNotThrowAnyException();
+ }
+
+ @Test
+ void defaultConfigurationTest() {
+
+
Assertions.assertThat(context.getBean(JolokiaComponentConfiguration.class))
+ .as("check starter configuration")
+ .hasOnlyFields("enabled", "lookupConfig",
"lookupServices",
+ "systemPropertiesMode",
"exposeApplicationContext", "serverConfig",
+ "kubernetesDiscover",
"kubernetesUseDefaultCa", "useCamelRestrictor", "configFromPropertiesFirst")
+ .hasFieldOrPropertyWithValue("enabled", true)
+ .hasFieldOrPropertyWithValue("lookupConfig",
false)
+ .hasFieldOrPropertyWithValue("lookupServices",
false)
+
.hasFieldOrPropertyWithValue("systemPropertiesMode", "never")
+
.hasFieldOrPropertyWithValue("exposeApplicationContext", false)
+
.hasFieldOrPropertyWithValue("kubernetesDiscover", true)
+
.hasFieldOrPropertyWithValue("kubernetesUseDefaultCa", true)
+
.hasFieldOrPropertyWithValue("useCamelRestrictor", true)
+
.hasFieldOrPropertyWithValue("configFromPropertiesFirst", true);
+
+ Assertions.assertThat(agent)
+ .describedAs("check the default configHolder
properties")
+ .extracting("configHolder").isNotNull()
+ .extracting("config")
+
.asInstanceOf(InstanceOfAssertFactories.map(String.class, String.class))
+ .containsEntry("host", "0.0.0.0")
+ .containsEntry("autoStart", "true")
+ .containsEntry("restrictorClass",
CamelRestrictor.class.getCanonicalName());
+
+ Assertions.assertThat(agent).as("check default agent/server
configuration")
+ .hasFieldOrPropertyWithValue("lookupConfig",
false)
+ .hasFieldOrPropertyWithValue("lookupServices",
false)
+
.hasFieldOrPropertyWithValue("exposeApplicationContext", false)
+
.hasFieldOrPropertyWithValue("systemPropertyMode", SystemPropertyMode.NEVER)
+ .hasFieldOrProperty("config").isNotNull()
+ .extracting("config")
+
.hasFieldOrPropertyWithValue("protocol", "http")
+ .hasFieldOrPropertyWithValue("context",
"/jolokia/");
+ }
+}
diff --git
a/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationUsingConfigHolderTest.java
b/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationUsingConfigHolderTest.java
new file mode 100644
index 00000000000..61f9bdb69b2
--- /dev/null
+++
b/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationUsingConfigHolderTest.java
@@ -0,0 +1,37 @@
+/*
+ * 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.jolokia.springboot;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest(classes = {CamelAutoConfiguration.class,
JolokiaComponentAutoConfiguration.class},
+ properties = "camel.component.jolokia.serverConfig.port=0")
+public class JolokiaComponentAutoConfigurationUsingConfigHolderTest extends
JolokiaComponentTestBase {
+
+ @Test
+ void randomPortTest() {
+ assertThat(agent.getAddress().getPort())
+ .describedAs("check the port is configured from
config holder")
+ .isGreaterThan(0);
+ }
+}
diff --git
a/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationUsingCustomBeansTest.java
b/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationUsingCustomBeansTest.java
new file mode 100644
index 00000000000..bde083678aa
--- /dev/null
+++
b/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationUsingCustomBeansTest.java
@@ -0,0 +1,73 @@
+/*
+ * 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.jolokia.springboot;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+import org.assertj.core.api.Assertions;
+import org.jolokia.support.spring.SpringJolokiaConfigHolder;
+import org.jolokia.support.spring.SpringJolokiaLogHandlerHolder;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import java.util.Map;
+
+@SpringBootTest(classes =
{JolokiaComponentAutoConfigurationUsingCustomBeansTest.TestConfiguration.class,
CamelAutoConfiguration.class, JolokiaComponentAutoConfiguration.class},
+ properties = {"camel.component.jolokia.serverConfig.port=0",
"logging.level.org.apache.camel.component.jolokia=TRACE"})
+public class JolokiaComponentAutoConfigurationUsingCustomBeansTest extends
JolokiaComponentTestBase {
+
+ @Test
+ void checkCustomConfigurationByCode() {
+ assertThat(agent.getServerConfig().getThreadNr())
+ .describedAs("check the thread number is
configured from custom config holder")
+ .isEqualTo(5);
+ }
+
+ @Test
+ void checkCustomLogConfigurationByCode() {
+ Assertions.assertThat(agent).describedAs("check the log
configuration cames from custom log holder")
+ .extracting("logHandlerHolder")
+ .hasFieldOrPropertyWithValue("type", "stdout");
+ }
+
+ // *************************************
+ // Config
+ // *************************************
+
+ @Configuration
+ public static class TestConfiguration {
+
+ @Bean("camelConfigHolder")
+ public SpringJolokiaConfigHolder configHolder() {
+ final SpringJolokiaConfigHolder myConfig = new
SpringJolokiaConfigHolder();
+ myConfig.setConfig(Map.of("threadNr", "5", "executor",
"fixed"));
+ return myConfig;
+ }
+
+ @Bean("camelLogHandlerHolder")
+ public SpringJolokiaLogHandlerHolder logHandlerHolder() {
+ final SpringJolokiaLogHandlerHolder logHandlerHolder =
new SpringJolokiaLogHandlerHolder();
+ logHandlerHolder.setType("stdout");
+ return logHandlerHolder;
+ }
+ }
+}
diff --git
a/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationUsingSystemPropertiesTest.java
b/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationUsingSystemPropertiesTest.java
new file mode 100644
index 00000000000..cd833f3e432
--- /dev/null
+++
b/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationUsingSystemPropertiesTest.java
@@ -0,0 +1,62 @@
+/*
+ * 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.jolokia.springboot;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import org.assertj.core.api.Assertions;
+import org.jolokia.support.spring.SystemPropertyMode;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.util.TestSocketUtils;
+
+import java.util.Map;
+
+@SpringBootTest(classes = {CamelAutoConfiguration.class,
JolokiaComponentAutoConfiguration.class},
+ properties =
"camel.component.jolokia.systemPropertiesMode=override")
+public class JolokiaComponentAutoConfigurationUsingSystemPropertiesTest
extends JolokiaComponentTestBase {
+
+ private static final Map<String, String> SYS_VARS =
Map.of("jolokia.port", String.valueOf(TestSocketUtils.findAvailableTcpPort()));
+
+ @BeforeAll
+ public static void setSystemProperties() {
+ SYS_VARS.entrySet().forEach(e -> System.setProperty(e.getKey(),
e.getValue()));
+ }
+
+ @AfterAll
+ public static void cleanSystemProperties() {
+ SYS_VARS.keySet().forEach(System::clearProperty);
+ }
+
+ @Test
+ void systemPropertyTest() {
+ Assertions.assertThat(agent).as("check systemPropertiesMode
property on agent")
+
.hasFieldOrPropertyWithValue("systemPropertyMode", SystemPropertyMode.OVERRIDE);
+ }
+
+ @Test
+ void customPortTest() {
+ assertThat(agent.getAddress().getPort())
+ .describedAs("check the port is configured from
system property")
+
.isEqualTo(Integer.parseInt(SYS_VARS.get("jolokia.port")));
+ }
+}
diff --git
a/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationWithoutRestrictorTest.java
b/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationWithoutRestrictorTest.java
new file mode 100644
index 00000000000..83f885cc1b1
--- /dev/null
+++
b/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentAutoConfigurationWithoutRestrictorTest.java
@@ -0,0 +1,47 @@
+/*
+ * 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.jolokia.springboot;
+
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+import org.assertj.core.api.Assertions;
+import org.assertj.core.api.InstanceOfAssertFactories;
+import org.jolokia.server.core.config.ConfigKey;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest(classes = {CamelAutoConfiguration.class,
JolokiaComponentAutoConfiguration.class},
+ properties = {"camel.component.jolokia.serverConfig.port=0",
+
"camel.component.jolokia.useCamelRestrictor=false"})
+public class JolokiaComponentAutoConfigurationWithoutRestrictorTest extends
JolokiaComponentTestBase {
+
+ @Test
+ void checkConfigurationTest() {
+
+ Assertions.assertThat(agent)
+ .describedAs("check the configHolder
restrictorClass property")
+ .extracting("configHolder").isNotNull()
+ .extracting("config")
+
.asInstanceOf(InstanceOfAssertFactories.map(String.class, String.class))
+
.doesNotContainKey(ConfigKey.RESTRICTOR_CLASS.getKeyValue());
+
+
Assertions.assertThat(agent.getServerConfig().getJolokiaConfig().containsKey(ConfigKey.RESTRICTOR_CLASS))
+ .as("check the jolokia config")
+ .isFalse();
+ }
+}
diff --git
a/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentTestBase.java
b/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentTestBase.java
new file mode 100644
index 00000000000..096ad25bc30
--- /dev/null
+++
b/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/JolokiaComponentTestBase.java
@@ -0,0 +1,35 @@
+/*
+ * 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.jolokia.springboot;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+
+import org.junit.jupiter.api.BeforeEach;
+
+import org.jolokia.support.spring.SpringJolokiaAgent;
+import org.springframework.beans.factory.annotation.Autowired;
+
+class JolokiaComponentTestBase {
+
+ @Autowired(required = false)
+ protected SpringJolokiaAgent agent;
+
+ @BeforeEach
+ void checkAgentIsAutoWired() {
+ assertThat(agent).isNotNull();
+ }
+}
diff --git
a/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/support/MyRestrictor.java
b/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/support/MyRestrictor.java
new file mode 100644
index 00000000000..154a9edd32a
--- /dev/null
+++
b/components-starter/camel-jolokia-starter/src/test/java/org/apache/camel/component/jolokia/springboot/support/MyRestrictor.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.jolokia.springboot.support;
+
+import
org.apache.camel.component.jolokia.springboot.restrictor.CamelRestrictor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class MyRestrictor extends CamelRestrictor {
+
+ @Override
+ protected List<String> getAllowedDomains() {
+ final List<String> newDomains = new
ArrayList<>(getDefaultDomains());
+ newDomains.add("my.domain");
+ return newDomains;
+ }
+}
diff --git a/components-starter/pom.xml b/components-starter/pom.xml
index 397e3240ca7..66d53a53803 100644
--- a/components-starter/pom.xml
+++ b/components-starter/pom.xml
@@ -279,6 +279,7 @@
<module>camel-jira-starter</module>
<module>camel-jms-starter</module>
<module>camel-jmx-starter</module>
+ <module>camel-jolokia-starter</module>
<module>camel-jolt-starter</module>
<module>camel-jooq-starter</module>
<module>camel-joor-starter</module>
diff --git a/pom.xml b/pom.xml
index e3888d7262d..d00ab143b05 100644
--- a/pom.xml
+++ b/pom.xml
@@ -131,6 +131,7 @@
<surefire.version>${maven-surefire-plugin-version}</surefire.version>
<swagger-parser-v3-version>2.1.10</swagger-parser-v3-version>
<cyclonedx-maven-plugin-version>2.8.1</cyclonedx-maven-plugin-version>
+ <jolokia-version>2.1.1</jolokia-version>
</properties>
diff --git a/tooling/camel-spring-boot-bom/pom.xml
b/tooling/camel-spring-boot-bom/pom.xml
index 8a68bb5337d..db3a5ced48d 100644
--- a/tooling/camel-spring-boot-bom/pom.xml
+++ b/tooling/camel-spring-boot-bom/pom.xml
@@ -938,6 +938,11 @@
<artifactId>camel-jmx-starter</artifactId>
<version>4.9.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.springboot</groupId>
+ <artifactId>camel-jolokia-starter</artifactId>
+ <version>4.9.0-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-jolt-starter</artifactId>
diff --git a/tooling/camel-spring-boot-dependencies/pom.xml
b/tooling/camel-spring-boot-dependencies/pom.xml
index a82f701247e..0305d2d7d4c 100644
--- a/tooling/camel-spring-boot-dependencies/pom.xml
+++ b/tooling/camel-spring-boot-dependencies/pom.xml
@@ -1192,6 +1192,11 @@
<artifactId>camel-jmx-starter</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.springboot</groupId>
+ <artifactId>camel-jolokia-starter</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-jolt-starter</artifactId>