Search in sources :

Example 1 with AnnotationMBeanExporter

use of org.springframework.jmx.export.annotation.AnnotationMBeanExporter in project spring-framework by spring-projects.

the class MBeanExportConfiguration method mbeanExporter.

@Bean(name = MBEAN_EXPORTER_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public AnnotationMBeanExporter mbeanExporter() {
    AnnotationMBeanExporter exporter = new AnnotationMBeanExporter();
    Assert.state(this.enableMBeanExport != null, "No EnableMBeanExport annotation found");
    setupDomain(exporter, this.enableMBeanExport);
    setupServer(exporter, this.enableMBeanExport);
    setupRegistrationPolicy(exporter, this.enableMBeanExport);
    return exporter;
}
Also used : AnnotationMBeanExporter(org.springframework.jmx.export.annotation.AnnotationMBeanExporter)

Example 2 with AnnotationMBeanExporter

use of org.springframework.jmx.export.annotation.AnnotationMBeanExporter in project spring-boot by spring-projects.

the class JmxAutoConfiguration method mbeanExporter.

@Bean
@Primary
@ConditionalOnMissingBean(value = MBeanExporter.class, search = SearchStrategy.CURRENT)
public AnnotationMBeanExporter mbeanExporter(ObjectNamingStrategy namingStrategy, BeanFactory beanFactory) {
    AnnotationMBeanExporter exporter = new AnnotationMBeanExporter();
    exporter.setRegistrationPolicy(RegistrationPolicy.FAIL_ON_EXISTING);
    exporter.setNamingStrategy(namingStrategy);
    String serverBean = this.environment.getProperty("spring.jmx.server", "mbeanServer");
    if (StringUtils.hasLength(serverBean)) {
        exporter.setServer(beanFactory.getBean(serverBean, MBeanServer.class));
    }
    return exporter;
}
Also used : AnnotationMBeanExporter(org.springframework.jmx.export.annotation.AnnotationMBeanExporter) MBeanServer(javax.management.MBeanServer) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Primary(org.springframework.context.annotation.Primary) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) MBeanServerFactoryBean(org.springframework.jmx.support.MBeanServerFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 3 with AnnotationMBeanExporter

use of org.springframework.jmx.export.annotation.AnnotationMBeanExporter in project spring-boot by spring-projects.

the class JmxAutoConfiguration method mbeanExporter.

@Bean
@Primary
@ConditionalOnMissingBean(value = MBeanExporter.class, search = SearchStrategy.CURRENT)
public AnnotationMBeanExporter mbeanExporter(ObjectNamingStrategy namingStrategy) {
    AnnotationMBeanExporter exporter = new AnnotationMBeanExporter();
    exporter.setRegistrationPolicy(RegistrationPolicy.FAIL_ON_EXISTING);
    exporter.setNamingStrategy(namingStrategy);
    String server = this.propertyResolver.getProperty("server", "mbeanServer");
    if (StringUtils.hasLength(server)) {
        exporter.setServer(this.beanFactory.getBean(server, MBeanServer.class));
    }
    return exporter;
}
Also used : AnnotationMBeanExporter(org.springframework.jmx.export.annotation.AnnotationMBeanExporter) MBeanServer(javax.management.MBeanServer) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Primary(org.springframework.context.annotation.Primary) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) MBeanServerFactoryBean(org.springframework.jmx.support.MBeanServerFactoryBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

AnnotationMBeanExporter (org.springframework.jmx.export.annotation.AnnotationMBeanExporter)3 MBeanServer (javax.management.MBeanServer)2 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)2 Bean (org.springframework.context.annotation.Bean)2 Primary (org.springframework.context.annotation.Primary)2 MBeanServerFactoryBean (org.springframework.jmx.support.MBeanServerFactoryBean)2