Search in sources :

Example 1 with RegistrationPolicy

use of org.springframework.jmx.support.RegistrationPolicy in project spring-framework by spring-projects.

the class MBeanExportConfiguration method setupRegistrationPolicy.

private void setupRegistrationPolicy(AnnotationMBeanExporter exporter) {
    RegistrationPolicy registrationPolicy = this.enableMBeanExport.getEnum("registration");
    exporter.setRegistrationPolicy(registrationPolicy);
}
Also used : RegistrationPolicy(org.springframework.jmx.support.RegistrationPolicy)

Example 2 with RegistrationPolicy

use of org.springframework.jmx.support.RegistrationPolicy in project spring-framework by spring-projects.

the class MBeanExportBeanDefinitionParser method parseInternal.

@Override
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
    BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(AnnotationMBeanExporter.class);
    // Mark as infrastructure bean and attach source location.
    builder.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
    builder.getRawBeanDefinition().setSource(parserContext.extractSource(element));
    String defaultDomain = element.getAttribute(DEFAULT_DOMAIN_ATTRIBUTE);
    if (StringUtils.hasText(defaultDomain)) {
        builder.addPropertyValue("defaultDomain", defaultDomain);
    }
    String serverBeanName = element.getAttribute(SERVER_ATTRIBUTE);
    if (StringUtils.hasText(serverBeanName)) {
        builder.addPropertyReference("server", serverBeanName);
    } else {
        AbstractBeanDefinition specialServer = MBeanServerBeanDefinitionParser.findServerForSpecialEnvironment();
        if (specialServer != null) {
            builder.addPropertyValue("server", specialServer);
        }
    }
    String registration = element.getAttribute(REGISTRATION_ATTRIBUTE);
    RegistrationPolicy registrationPolicy = RegistrationPolicy.FAIL_ON_EXISTING;
    if (REGISTRATION_IGNORE_EXISTING.equals(registration)) {
        registrationPolicy = RegistrationPolicy.IGNORE_EXISTING;
    } else if (REGISTRATION_REPLACE_EXISTING.equals(registration)) {
        registrationPolicy = RegistrationPolicy.REPLACE_EXISTING;
    }
    builder.addPropertyValue("registrationPolicy", registrationPolicy);
    return builder.getBeanDefinition();
}
Also used : BeanDefinitionBuilder(org.springframework.beans.factory.support.BeanDefinitionBuilder) AbstractBeanDefinition(org.springframework.beans.factory.support.AbstractBeanDefinition) RegistrationPolicy(org.springframework.jmx.support.RegistrationPolicy)

Aggregations

RegistrationPolicy (org.springframework.jmx.support.RegistrationPolicy)2 AbstractBeanDefinition (org.springframework.beans.factory.support.AbstractBeanDefinition)1 BeanDefinitionBuilder (org.springframework.beans.factory.support.BeanDefinitionBuilder)1