本文整理汇总了Java中org.springframework.jmx.support.RegistrationPolicy类的典型用法代码示例。如果您正苦于以下问题:Java RegistrationPolicy类的具体用法?Java RegistrationPolicy怎么用?Java RegistrationPolicy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RegistrationPolicy类属于org.springframework.jmx.support包,在下文中一共展示了RegistrationPolicy类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseInternal
import org.springframework.jmx.support.RegistrationPolicy; //导入依赖的package包/类
@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();
}
示例2: testRegisterReplaceExisting
import org.springframework.jmx.support.RegistrationPolicy; //导入依赖的package包/类
@Test
public void testRegisterReplaceExisting() throws Exception {
ObjectName objectName = ObjectNameManager.getInstance(OBJECT_NAME);
Person preRegistered = new Person();
preRegistered.setName("Rob Harrop");
server.registerMBean(preRegistered, objectName);
Person springRegistered = new Person();
springRegistered.setName("Sally Greenwood");
Map<String, Object> beans = new HashMap<String, Object>();
beans.put(objectName.toString(), springRegistered);
MBeanExporter exporter = new MBeanExporter();
exporter.setServer(server);
exporter.setBeans(beans);
exporter.setRegistrationPolicy(RegistrationPolicy.REPLACE_EXISTING);
start(exporter);
ObjectInstance instance = server.getObjectInstance(objectName);
assertNotNull(instance);
// should still be the new bean with name Sally Greenwood
assertEquals("Sally Greenwood", server.getAttribute(objectName, "Name"));
}
示例3: mbeanExporter
import org.springframework.jmx.support.RegistrationPolicy; //导入依赖的package包/类
@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;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:JmxAutoConfiguration.java
示例4: mbeanExporter
import org.springframework.jmx.support.RegistrationPolicy; //导入依赖的package包/类
/**
* Special MBeanExporter bean for integration tests.
*
* @return MBeanExporter with a different registration strategy
*/
@Bean
@Profile("itest")
public MBeanExporter mbeanExporter() {
MBeanExporter exporter = new MBeanExporter();
exporter.setRegistrationPolicy(RegistrationPolicy.REPLACE_EXISTING);
return exporter;
}
示例5: testRegisterReplaceExisting
import org.springframework.jmx.support.RegistrationPolicy; //导入依赖的package包/类
@Test
public void testRegisterReplaceExisting() throws Exception {
ObjectName objectName = ObjectNameManager.getInstance(OBJECT_NAME);
Person preRegistered = new Person();
preRegistered.setName("Rob Harrop");
server.registerMBean(preRegistered, objectName);
Person springRegistered = new Person();
springRegistered.setName("Sally Greenwood");
Map<String, Object> beans = new HashMap<String, Object>();
beans.put(objectName.toString(), springRegistered);
MBeanExporter exporter = new MBeanExporter();
exporter.setServer(server);
exporter.setBeans(beans);
exporter.setRegistrationPolicy(RegistrationPolicy.REPLACE_EXISTING);
exporter.afterPropertiesSet();
ObjectInstance instance = server.getObjectInstance(objectName);
assertNotNull(instance);
// should still be the new bean with name Sally Greenwood
assertEquals("Sally Greenwood", server.getAttribute(objectName, "Name"));
}
示例6: setupRegistrationPolicy
import org.springframework.jmx.support.RegistrationPolicy; //导入依赖的package包/类
private void setupRegistrationPolicy(AnnotationMBeanExporter exporter) {
RegistrationPolicy registrationPolicy = this.attributes.getEnum("registration");
exporter.setRegistrationPolicy(registrationPolicy);
}
示例7: setupRegistrationPolicy
import org.springframework.jmx.support.RegistrationPolicy; //导入依赖的package包/类
private void setupRegistrationPolicy(AnnotationMBeanExporter exporter) {
RegistrationPolicy registrationPolicy = this.enableMBeanExport.getEnum("registration");
exporter.setRegistrationPolicy(registrationPolicy);
}