Skip to content

Commit e92cb11

Browse files
committed
Merge branch 'gh-9843'
2 parents 2eb3da5 + a3f5aaa commit e92cb11

16 files changed

+347
-728
lines changed

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/jolokia/JolokiaAutoConfiguration.java

Lines changed: 0 additions & 119 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
* Copyright 2012-2017 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.actuate.autoconfigure.jolokia;
18+
19+
import org.jolokia.http.AgentServlet;
20+
21+
import org.springframework.boot.actuate.autoconfigure.ManagementContextConfiguration;
22+
import org.springframework.boot.actuate.endpoint.mvc.ManagementServletContext;
23+
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
24+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
25+
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
26+
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
27+
import org.springframework.boot.context.properties.EnableConfigurationProperties;
28+
import org.springframework.boot.web.servlet.ServletRegistrationBean;
29+
import org.springframework.context.annotation.Bean;
30+
import org.springframework.web.servlet.mvc.ServletWrappingController;
31+
32+
/**
33+
* {@link ManagementContextConfiguration} for embedding Jolokia, a JMX-HTTP bridge giving
34+
* an alternative to JSR-160 connectors.
35+
*
36+
* <p>
37+
* This configuration will get automatically enabled as soon as the Jolokia
38+
* {@link AgentServlet} is on the classpath. To disable it set
39+
* {@code management.jolokia.enabled=false}.
40+
*
41+
* <p>
42+
* Additional configuration parameters for Jolokia can be provided by specifying
43+
* {@code management.jolokia.config.*} properties. See the
44+
* <a href="http://jolokia.org">http://jolokia.org</a> web site for more information on
45+
* supported configuration parameters.
46+
*
47+
* @author Christian Dupuis
48+
* @author Dave Syer
49+
* @author Andy Wilkinson
50+
* @author Madhura Bhave
51+
* @author Stephane Nicoll
52+
* @since 2.0.0
53+
*/
54+
@ManagementContextConfiguration
55+
@ConditionalOnWebApplication(type = Type.SERVLET)
56+
@ConditionalOnClass({ AgentServlet.class, ServletWrappingController.class })
57+
@ConditionalOnProperty(value = "management.jolokia.enabled", matchIfMissing = true)
58+
@EnableConfigurationProperties(JolokiaProperties.class)
59+
public class JolokiaManagementContextConfiguration {
60+
61+
private final ManagementServletContext managementServletContext;
62+
63+
private final JolokiaProperties properties;
64+
65+
public JolokiaManagementContextConfiguration(
66+
ManagementServletContext managementServletContext,
67+
JolokiaProperties properties) {
68+
this.managementServletContext = managementServletContext;
69+
this.properties = properties;
70+
}
71+
72+
@Bean
73+
public ServletRegistrationBean<AgentServlet> jolokiaServlet() {
74+
String path = this.managementServletContext.getContextPath()
75+
+ this.properties.getPath();
76+
String urlMapping = (path.endsWith("/") ? path + "*" : path + "/*");
77+
ServletRegistrationBean<AgentServlet> registration = new ServletRegistrationBean<>(
78+
new AgentServlet(), urlMapping);
79+
registration.setInitParameters(this.properties.getConfig());
80+
return registration;
81+
}
82+
83+
}

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/jolokia/JolokiaProperties.java

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,46 @@
2626
*
2727
* @author Christian Dupuis
2828
* @author Dave Syer
29+
* @author Stephane Nicoll
2930
* @since 2.0.0
3031
*/
31-
@ConfigurationProperties(prefix = "jolokia")
32+
@ConfigurationProperties(prefix = "management.jolokia")
3233
public class JolokiaProperties {
3334

35+
/**
36+
* Enable Jolokia.
37+
*/
38+
private boolean enabled = true;
39+
40+
/**
41+
* Path at which Jolokia will be available.
42+
*/
43+
private String path = "/jolokia";
44+
3445
/**
3546
* Jolokia settings. These are traditionally set using servlet parameters. Refer to
3647
* the documentation of Jolokia for more details.
3748
*/
38-
private Map<String, String> config = new HashMap<>();
49+
private final Map<String, String> config = new HashMap<>();
3950

40-
public Map<String, String> getConfig() {
41-
return this.config;
51+
public boolean isEnabled() {
52+
return this.enabled;
4253
}
4354

44-
public void setConfig(Map<String, String> config) {
45-
this.config = config;
55+
public void setEnabled(boolean enabled) {
56+
this.enabled = enabled;
57+
}
58+
59+
public String getPath() {
60+
return this.path;
61+
}
62+
63+
public void setPath(String path) {
64+
this.path = path;
65+
}
66+
67+
public Map<String, String> getConfig() {
68+
return this.config;
4669
}
4770

4871
}

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/JolokiaMvcEndpoint.java

Lines changed: 0 additions & 121 deletions
This file was deleted.

spring-boot-actuator/src/main/resources/META-INF/spring.factories

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ org.springframework.boot.actuate.autoconfigure.endpoint.EndpointMBeanExportAutoC
66
org.springframework.boot.actuate.autoconfigure.endpoint.EndpointWebMvcAutoConfiguration,\
77
org.springframework.boot.actuate.autoconfigure.health.HealthIndicatorAutoConfiguration,\
88
org.springframework.boot.actuate.autoconfigure.info.InfoContributorAutoConfiguration,\
9-
org.springframework.boot.actuate.autoconfigure.jolokia.JolokiaAutoConfiguration,\
109
org.springframework.boot.actuate.autoconfigure.security.ManagementWebSecurityAutoConfiguration,\
1110
org.springframework.boot.actuate.autoconfigure.metrics.MetricFilterAutoConfiguration,\
1211
org.springframework.boot.actuate.autoconfigure.metrics.MetricRepositoryAutoConfiguration,\
@@ -19,4 +18,5 @@ org.springframework.boot.actuate.autoconfigure.trace.TraceWebFilterAutoConfigura
1918
org.springframework.boot.actuate.autoconfigure.cloudfoundry.CloudFoundryActuatorAutoConfiguration
2019

2120
org.springframework.boot.actuate.autoconfigure.ManagementContextConfiguration=\
22-
org.springframework.boot.actuate.autoconfigure.endpoint.EndpointWebMvcManagementContextConfiguration
21+
org.springframework.boot.actuate.autoconfigure.endpoint.EndpointWebMvcManagementContextConfiguration,\
22+
org.springframework.boot.actuate.autoconfigure.jolokia.JolokiaManagementContextConfiguration

0 commit comments

Comments
 (0)