org.springframework.jmx.export.annotation.AnnotationMBeanExporter Java Examples

The following examples show how to use org.springframework.jmx.export.annotation.AnnotationMBeanExporter. 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: MBeanExportConfiguration.java    From spring-analysis-note with MIT License 6 votes vote down vote up
private void setupServer(AnnotationMBeanExporter exporter, AnnotationAttributes enableMBeanExport) {
	String server = enableMBeanExport.getString("server");
	if (StringUtils.hasLength(server) && this.environment != null) {
		server = this.environment.resolvePlaceholders(server);
	}
	if (StringUtils.hasText(server)) {
		Assert.state(this.beanFactory != null, "No BeanFactory set");
		exporter.setServer(this.beanFactory.getBean(server, MBeanServer.class));
	}
	else {
		SpecificPlatform specificPlatform = SpecificPlatform.get();
		if (specificPlatform != null) {
			MBeanServer mbeanServer = specificPlatform.getMBeanServer();
			if (mbeanServer != null) {
				exporter.setServer(mbeanServer);
			}
		}
	}
}
 
Example #2
Source File: MBeanExportConfiguration.java    From java-technology-stack with MIT License 6 votes vote down vote up
private void setupServer(AnnotationMBeanExporter exporter, AnnotationAttributes enableMBeanExport) {
	String server = enableMBeanExport.getString("server");
	if (StringUtils.hasLength(server) && this.environment != null) {
		server = this.environment.resolvePlaceholders(server);
	}
	if (StringUtils.hasText(server)) {
		Assert.state(this.beanFactory != null, "No BeanFactory set");
		exporter.setServer(this.beanFactory.getBean(server, MBeanServer.class));
	}
	else {
		SpecificPlatform specificPlatform = SpecificPlatform.get();
		if (specificPlatform != null) {
			MBeanServer mbeanServer = specificPlatform.getMBeanServer();
			if (mbeanServer != null) {
				exporter.setServer(mbeanServer);
			}
		}
	}
}
 
Example #3
Source File: MBeanExportConfiguration.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private void setupDomain(AnnotationMBeanExporter exporter, AnnotationAttributes enableMBeanExport) {
	String defaultDomain = enableMBeanExport.getString("defaultDomain");
	if (StringUtils.hasLength(defaultDomain) && this.environment != null) {
		defaultDomain = this.environment.resolvePlaceholders(defaultDomain);
	}
	if (StringUtils.hasText(defaultDomain)) {
		exporter.setDefaultDomain(defaultDomain);
	}
}
 
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();
}
 
Example #5
Source File: MBeanExportConfiguration.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private void setupServer(AnnotationMBeanExporter exporter) {
	String server = this.enableMBeanExport.getString("server");
	if (server != null && this.environment != null) {
		server = this.environment.resolvePlaceholders(server);
	}
	if (StringUtils.hasText(server)) {
		exporter.setServer(this.beanFactory.getBean(server, MBeanServer.class));
	}
	else {
		SpecificPlatform specificPlatform = SpecificPlatform.get();
		if (specificPlatform != null) {
			exporter.setServer(specificPlatform.getMBeanServer());
		}
	}
}
 
Example #6
Source File: MBeanExportConfiguration.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private void setupDomain(AnnotationMBeanExporter exporter) {
	String defaultDomain = this.enableMBeanExport.getString("defaultDomain");
	if (defaultDomain != null && this.environment != null) {
		defaultDomain = this.environment.resolvePlaceholders(defaultDomain);
	}
	if (StringUtils.hasText(defaultDomain)) {
		exporter.setDefaultDomain(defaultDomain);
	}
}
 
Example #7
Source File: MBeanExportConfiguration.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Bean(name = MBEAN_EXPORTER_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public AnnotationMBeanExporter mbeanExporter() {
	AnnotationMBeanExporter exporter = new AnnotationMBeanExporter();
	setupDomain(exporter);
	setupServer(exporter);
	setupRegistrationPolicy(exporter);
	return exporter;
}
 
Example #8
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 #9
Source File: MBeanExportConfiguration.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private void setupServer(AnnotationMBeanExporter exporter) {
	String server = this.enableMBeanExport.getString("server");
	if (server != null && this.environment != null) {
		server = this.environment.resolvePlaceholders(server);
	}
	if (StringUtils.hasText(server)) {
		exporter.setServer(this.beanFactory.getBean(server, MBeanServer.class));
	}
	else {
		SpecificPlatform specificPlatform = SpecificPlatform.get();
		if (specificPlatform != null) {
			exporter.setServer(specificPlatform.getMBeanServer());
		}
	}
}
 
Example #10
Source File: MBeanExportConfiguration.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
private void setupDomain(AnnotationMBeanExporter exporter) {
	String defaultDomain = this.enableMBeanExport.getString("defaultDomain");
	if (defaultDomain != null && this.environment != null) {
		defaultDomain = this.environment.resolvePlaceholders(defaultDomain);
	}
	if (StringUtils.hasText(defaultDomain)) {
		exporter.setDefaultDomain(defaultDomain);
	}
}
 
Example #11
Source File: MBeanExportConfiguration.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Bean(name = MBEAN_EXPORTER_BEAN_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public AnnotationMBeanExporter mbeanExporter() {
	AnnotationMBeanExporter exporter = new AnnotationMBeanExporter();
	setupDomain(exporter);
	setupServer(exporter);
	setupRegistrationPolicy(exporter);
	return exporter;
}
 
Example #12
Source File: SpringApplicationBootstrap.java    From thinking-in-spring-boot-samples with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
    // 启动 Spring Boot 应用
    ConfigurableApplicationContext context = SpringApplication.run(SpringApplicationConfiguration.class, args);
    // 获取 AnnotationMBeanExporter Bean
    AnnotationMBeanExporter beanExporter = context.getBean(AnnotationMBeanExporter.class);
    // 输出 AnnotationMBeanExporter 对象
    System.out.println("AnnotationMBeanExporter Bean : " + beanExporter);
    // 输出 SpringApplicationConfiguration 对象
    System.out.println("SpringApplicationConfiguration Bean : " + context.getBean(SpringApplicationConfiguration.class));
    // 关闭上下文
    context.close();
}
 
Example #13
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 #14
Source File: MBeanExportConfiguration.java    From java-technology-stack with MIT License 5 votes vote down vote up
private void setupDomain(AnnotationMBeanExporter exporter, AnnotationAttributes enableMBeanExport) {
	String defaultDomain = enableMBeanExport.getString("defaultDomain");
	if (StringUtils.hasLength(defaultDomain) && this.environment != null) {
		defaultDomain = this.environment.resolvePlaceholders(defaultDomain);
	}
	if (StringUtils.hasText(defaultDomain)) {
		exporter.setDefaultDomain(defaultDomain);
	}
}
 
Example #15
Source File: MBeanExportConfiguration.java    From java-technology-stack with MIT License 5 votes vote down vote up
@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;
}
 
Example #16
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 #17
Source File: MBeanExportConfiguration.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@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;
}
 
Example #18
Source File: SpringJmxAnnotationBootstrap.java    From thinking-in-spring-boot-samples with Apache License 2.0 4 votes vote down vote up
@Bean
public AnnotationMBeanExporter mBeanExporter() {
    return new AnnotationMBeanExporter();
}
 
Example #19
Source File: MBeanExportConfiguration.java    From java-technology-stack with MIT License 4 votes vote down vote up
private void setupRegistrationPolicy(AnnotationMBeanExporter exporter, AnnotationAttributes enableMBeanExport) {
	RegistrationPolicy registrationPolicy = enableMBeanExport.getEnum("registration");
	exporter.setRegistrationPolicy(registrationPolicy);
}
 
Example #20
Source File: MBeanExportConfiguration.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
private void setupRegistrationPolicy(AnnotationMBeanExporter exporter) {
	RegistrationPolicy registrationPolicy = this.enableMBeanExport.getEnum("registration");
	exporter.setRegistrationPolicy(registrationPolicy);
}
 
Example #21
Source File: MBeanExportConfiguration.java    From spring-analysis-note with MIT License 4 votes vote down vote up
private void setupRegistrationPolicy(AnnotationMBeanExporter exporter, AnnotationAttributes enableMBeanExport) {
	RegistrationPolicy registrationPolicy = enableMBeanExport.getEnum("registration");
	exporter.setRegistrationPolicy(registrationPolicy);
}
 
Example #22
Source File: MBeanExportConfiguration.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
private void setupRegistrationPolicy(AnnotationMBeanExporter exporter) {
	RegistrationPolicy registrationPolicy = this.enableMBeanExport.getEnum("registration");
	exporter.setRegistrationPolicy(registrationPolicy);
}