Java Code Examples for org.springframework.jmx.support.RegistrationPolicy#REPLACE_EXISTING

The following examples show how to use org.springframework.jmx.support.RegistrationPolicy#REPLACE_EXISTING . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MBeanExportBeanDefinitionParser.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@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();
}
 
Example 2
Source File: MBeanExportBeanDefinitionParser.java    From java-technology-stack with MIT License 5 votes vote down vote up
@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();
}
 
Example 3
Source File: MBeanExportBeanDefinitionParser.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@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();
}
 
Example 4
Source File: MBeanExportBeanDefinitionParser.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@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();
}