|
|
|
|
@ -16,15 +16,19 @@
@@ -16,15 +16,19 @@
|
|
|
|
|
|
|
|
|
|
package org.springframework.boot.actuate.autoconfigure; |
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.boot.actuate.endpoint.Endpoint; |
|
|
|
|
import org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanExporter; |
|
|
|
|
import org.springframework.boot.autoconfigure.AutoConfigureAfter; |
|
|
|
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; |
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; |
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; |
|
|
|
|
import org.springframework.boot.bind.RelaxedPropertyResolver; |
|
|
|
|
import org.springframework.context.annotation.Bean; |
|
|
|
|
import org.springframework.context.annotation.Configuration; |
|
|
|
|
import org.springframework.core.env.Environment; |
|
|
|
|
import org.springframework.jmx.export.MBeanExporter; |
|
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* {@link EnableAutoConfiguration Auto-configuration} to enable JMX export for |
|
|
|
|
@ -38,10 +42,24 @@ import org.springframework.jmx.export.MBeanExporter;
@@ -38,10 +42,24 @@ import org.springframework.jmx.export.MBeanExporter;
|
|
|
|
|
@ConditionalOnExpression("${endpoints.jmx.enabled:true}") |
|
|
|
|
class EndpointMBeanExportAutoConfiguration { |
|
|
|
|
|
|
|
|
|
private RelaxedPropertyResolver environment; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
public void setEnvironment(Environment environment) { |
|
|
|
|
this.environment = new RelaxedPropertyResolver(environment); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Bean |
|
|
|
|
public EndpointMBeanExporter endpointMBeanExporter() { |
|
|
|
|
// TODO add configuration for domain name
|
|
|
|
|
return new EndpointMBeanExporter(); |
|
|
|
|
EndpointMBeanExporter mbeanExporter = new EndpointMBeanExporter(); |
|
|
|
|
String domainName = this.environment.getProperty("endpoints.jmx.domain_name"); |
|
|
|
|
if (StringUtils.hasText(domainName)) { |
|
|
|
|
mbeanExporter.setDomainName(domainName); |
|
|
|
|
} |
|
|
|
|
String key = this.environment.getProperty("endpoints.jmx.key"); |
|
|
|
|
if (StringUtils.hasText(key)) { |
|
|
|
|
mbeanExporter.setKey(key); |
|
|
|
|
} |
|
|
|
|
return mbeanExporter; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |