当前位置: 首页>>代码示例>>Java>>正文


Java MBeanExporter类代码示例

本文整理汇总了Java中org.springframework.jmx.export.MBeanExporter的典型用法代码示例。如果您正苦于以下问题:Java MBeanExporter类的具体用法?Java MBeanExporter怎么用?Java MBeanExporter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MBeanExporter类属于org.springframework.jmx.export包,在下文中一共展示了MBeanExporter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testEndpointMBeanExporterWithProperties

import org.springframework.jmx.export.MBeanExporter; //导入依赖的package包/类
@Test
public void testEndpointMBeanExporterWithProperties() throws IntrospectionException,
		InstanceNotFoundException, MalformedObjectNameException, ReflectionException {
	MockEnvironment environment = new MockEnvironment();
	environment.setProperty("endpoints.jmx.domain", "test-domain");
	environment.setProperty("endpoints.jmx.unique_names", "true");
	environment.setProperty("endpoints.jmx.static_names", "key1=value1, key2=value2");
	this.context = new AnnotationConfigApplicationContext();
	this.context.setEnvironment(environment);
	this.context.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class,
			EndpointMBeanExportAutoConfiguration.class);
	this.context.refresh();
	this.context.getBean(EndpointMBeanExporter.class);

	MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
	assertThat(mbeanExporter.getServer().getMBeanInfo(ObjectNameManager.getInstance(
			getObjectName("test-domain", "healthEndpoint", this.context).toString()
					+ ",key1=value1,key2=value2"))).isNotNull();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:20,代码来源:EndpointMBeanExportAutoConfigurationTests.java

示例2: testRegistrationTwoEndpoints

import org.springframework.jmx.export.MBeanExporter; //导入依赖的package包/类
@Test
public void testRegistrationTwoEndpoints() throws Exception {
	this.context = new GenericApplicationContext();
	this.context.registerBeanDefinition("endpointMbeanExporter",
			new RootBeanDefinition(EndpointMBeanExporter.class));
	this.context.registerBeanDefinition("endpoint1",
			new RootBeanDefinition(TestEndpoint.class));
	this.context.registerBeanDefinition("endpoint2",
			new RootBeanDefinition(TestEndpoint.class));
	this.context.refresh();
	MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
	assertThat(mbeanExporter.getServer()
			.getMBeanInfo(getObjectName("endpoint1", this.context))).isNotNull();
	assertThat(mbeanExporter.getServer()
			.getMBeanInfo(getObjectName("endpoint2", this.context))).isNotNull();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:EndpointMBeanExporterTests.java

示例3: testRegistrationWithDifferentDomainAndIdentity

import org.springframework.jmx.export.MBeanExporter; //导入依赖的package包/类
@Test
public void testRegistrationWithDifferentDomainAndIdentity() throws Exception {
	Map<String, Object> properties = new HashMap<String, Object>();
	properties.put("domain", "test-domain");
	properties.put("ensureUniqueRuntimeObjectNames", true);
	this.context = new GenericApplicationContext();
	this.context.registerBeanDefinition("endpointMbeanExporter",
			new RootBeanDefinition(EndpointMBeanExporter.class, null,
					new MutablePropertyValues(properties)));
	this.context.registerBeanDefinition("endpoint1",
			new RootBeanDefinition(TestEndpoint.class));
	this.context.refresh();
	MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
	assertThat(mbeanExporter.getServer().getMBeanInfo(
			getObjectName("test-domain", "endpoint1", true, this.context)))
					.isNotNull();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:18,代码来源:EndpointMBeanExporterTests.java

示例4: testRegistrationWithDifferentDomainAndIdentityAndStaticNames

import org.springframework.jmx.export.MBeanExporter; //导入依赖的package包/类
@Test
public void testRegistrationWithDifferentDomainAndIdentityAndStaticNames()
		throws Exception {
	Map<String, Object> properties = new HashMap<String, Object>();
	properties.put("domain", "test-domain");
	properties.put("ensureUniqueRuntimeObjectNames", true);
	Properties staticNames = new Properties();
	staticNames.put("key1", "value1");
	staticNames.put("key2", "value2");
	properties.put("objectNameStaticProperties", staticNames);
	this.context = new GenericApplicationContext();
	this.context.registerBeanDefinition("endpointMbeanExporter",
			new RootBeanDefinition(EndpointMBeanExporter.class, null,
					new MutablePropertyValues(properties)));
	this.context.registerBeanDefinition("endpoint1",
			new RootBeanDefinition(TestEndpoint.class));
	this.context.refresh();
	MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
	assertThat(mbeanExporter.getServer().getMBeanInfo(ObjectNameManager.getInstance(
			getObjectName("test-domain", "endpoint1", true, this.context).toString()
					+ ",key1=value1,key2=value2"))).isNotNull();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:23,代码来源:EndpointMBeanExporterTests.java

示例5: testRegistrationWithParentContext

import org.springframework.jmx.export.MBeanExporter; //导入依赖的package包/类
@Test
public void testRegistrationWithParentContext() throws Exception {
	this.context = new GenericApplicationContext();
	this.context.registerBeanDefinition("endpointMbeanExporter",
			new RootBeanDefinition(EndpointMBeanExporter.class));
	this.context.registerBeanDefinition("endpoint1",
			new RootBeanDefinition(TestEndpoint.class));
	GenericApplicationContext parent = new GenericApplicationContext();
	this.context.setParent(parent);
	parent.refresh();
	this.context.refresh();
	MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
	assertThat(mbeanExporter.getServer()
			.getMBeanInfo(getObjectName("endpoint1", this.context))).isNotNull();
	parent.close();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:EndpointMBeanExporterTests.java

示例6: jsonMapConversionWithCustomObjectMapper

import org.springframework.jmx.export.MBeanExporter; //导入依赖的package包/类
@Test
public void jsonMapConversionWithCustomObjectMapper() throws Exception {
	this.context = new GenericApplicationContext();
	ConstructorArgumentValues constructorArgs = new ConstructorArgumentValues();
	ObjectMapper objectMapper = new ObjectMapper();
	objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd"));
	constructorArgs.addIndexedArgumentValue(0, objectMapper);
	this.context.registerBeanDefinition("endpointMbeanExporter",
			new RootBeanDefinition(EndpointMBeanExporter.class, constructorArgs,
					null));
	this.context.registerBeanDefinition("endpoint1",
			new RootBeanDefinition(JsonMapConversionEndpoint.class));
	this.context.refresh();
	MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
	Object response = mbeanExporter.getServer().invoke(
			getObjectName("endpoint1", this.context), "getData", new Object[0],
			new String[0]);
	assertThat(response).isInstanceOf(Map.class);
	assertThat(((Map<?, ?>) response).get("date")).isInstanceOf(String.class);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:21,代码来源:EndpointMBeanExporterTests.java

示例7: testDefaultDomainConfiguredOnMBeanExport

import org.springframework.jmx.export.MBeanExporter; //导入依赖的package包/类
@Test
public void testDefaultDomainConfiguredOnMBeanExport() {
	MockEnvironment env = new MockEnvironment();
	env.setProperty("spring.jmx.enabled", "true");
	env.setProperty("spring.jmx.default-domain", "my-test-domain");
	this.context = new AnnotationConfigApplicationContext();
	this.context.setEnvironment(env);
	this.context.register(TestConfiguration.class, JmxAutoConfiguration.class);
	this.context.refresh();
	MBeanExporter mBeanExporter = this.context.getBean(MBeanExporter.class);
	assertThat(mBeanExporter).isNotNull();
	MetadataNamingStrategy naming = (MetadataNamingStrategy) ReflectionTestUtils
			.getField(mBeanExporter, "namingStrategy");
	assertThat(ReflectionTestUtils.getField(naming, "defaultDomain"))
			.isEqualTo("my-test-domain");
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:JmxAutoConfigurationTests.java

示例8: mbeanDataSourceIsExcludedFromExport

import org.springframework.jmx.export.MBeanExporter; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void mbeanDataSourceIsExcludedFromExport()
		throws IllegalStateException, NamingException {
	DataSource dataSource = new BasicDataSource();
	configureJndi("foo", dataSource);

	this.context = new AnnotationConfigApplicationContext();
	EnvironmentTestUtils.addEnvironment(this.context,
			"spring.datasource.jndi-name:foo");
	this.context.register(JndiDataSourceAutoConfiguration.class,
			MBeanExporterConfiguration.class);
	this.context.refresh();

	assertThat(this.context.getBean(DataSource.class)).isEqualTo(dataSource);
	MBeanExporter exporter = this.context.getBean(MBeanExporter.class);
	Set<String> excludedBeans = (Set<String>) new DirectFieldAccessor(exporter)
			.getPropertyValue("excludedBeans");
	assertThat(excludedBeans).containsExactly("dataSource");
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:21,代码来源:JndiDataSourceAutoConfigurationTests.java

示例9: standardDataSourceIsNotExcludedFromExport

import org.springframework.jmx.export.MBeanExporter; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void standardDataSourceIsNotExcludedFromExport()
		throws IllegalStateException, NamingException {
	DataSource dataSource = new org.apache.commons.dbcp.BasicDataSource();
	configureJndi("foo", dataSource);

	this.context = new AnnotationConfigApplicationContext();
	EnvironmentTestUtils.addEnvironment(this.context,
			"spring.datasource.jndi-name:foo");
	this.context.register(JndiDataSourceAutoConfiguration.class,
			MBeanExporterConfiguration.class);
	this.context.refresh();

	assertThat(this.context.getBean(DataSource.class)).isEqualTo(dataSource);
	MBeanExporter exporter = this.context.getBean(MBeanExporter.class);
	Set<String> excludedBeans = (Set<String>) new DirectFieldAccessor(exporter)
			.getPropertyValue("excludedBeans");
	assertThat(excludedBeans).isEmpty();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:21,代码来源:JndiDataSourceAutoConfigurationTests.java

示例10: InMemoryLKVLiveMarketDataProvider

import org.springframework.jmx.export.MBeanExporter; //导入依赖的package包/类
public InMemoryLKVLiveMarketDataProvider(final LiveDataClient liveDataClient, final MarketDataAvailabilityFilter availabilityFilter, final MarketDataPermissionProvider permissionProvider,
    final UserPrincipal marketDataUser) {
  ArgumentChecker.notNull(liveDataClient, "liveDataClient");
  ArgumentChecker.notNull(availabilityFilter, "availabilityFilter");
  ArgumentChecker.notNull(permissionProvider, "permissionProvider");
  ArgumentChecker.notNull(marketDataUser, "marketDataUser");
  _liveDataClient = liveDataClient;
  // TODO: Should we use the default normalization rules from the live data client rather than hard code the standard rule set here?
  _availabilityProvider = availabilityFilter.withProvider(new LiveMarketDataAvailabilityProvider(StandardRules.getOpenGammaRuleSetId()));
  _underlyingProvider = new InMemoryLKVMarketDataProvider();
  _permissionProvider = permissionProvider;
  _marketDataUser = marketDataUser;

  try {
    MBeanServer jmxServer = ManagementFactory.getPlatformMBeanServer();
    ObjectName objectName = createObjectName();
    if (objectName != null) {
      MBeanExporter exporter = new MBeanExporter();
      exporter.setServer(jmxServer);
      exporter.registerManagedResource(this, objectName);
    }
  } catch (SecurityException e) {
    s_logger.warn("No permissions for platform MBean server - JMX will not be available", e);
  }
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:26,代码来源:InMemoryLKVLiveMarketDataProvider.java

示例11: testEndpointMBeanExporterWithProperties

import org.springframework.jmx.export.MBeanExporter; //导入依赖的package包/类
@Test
public void testEndpointMBeanExporterWithProperties() throws IntrospectionException,
		InstanceNotFoundException, MalformedObjectNameException, ReflectionException {
	MockEnvironment environment = new MockEnvironment();
	environment.setProperty("endpoints.jmx.domain", "test-domain");
	environment.setProperty("endpoints.jmx.unique_names", "true");
	environment.setProperty("endpoints.jmx.static_names", "key1=value1, key2=value2");
	this.context = new AnnotationConfigApplicationContext();
	this.context.setEnvironment(environment);
	this.context.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class,
			EndpointMBeanExportAutoConfiguration.class);
	this.context.refresh();
	this.context.getBean(EndpointMBeanExporter.class);

	MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);

	assertNotNull(mbeanExporter.getServer()
			.getMBeanInfo(ObjectNameManager.getInstance(
					getObjectName("test-domain", "healthEndpoint", this.context)
							.toString() + ",key1=value1,key2=value2")));
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:22,代码来源:EndpointMBeanExportAutoConfigurationTests.java

示例12: testRegistrationTwoEndpoints

import org.springframework.jmx.export.MBeanExporter; //导入依赖的package包/类
@Test
public void testRegistrationTwoEndpoints() throws Exception {
	this.context = new GenericApplicationContext();
	this.context.registerBeanDefinition("endpointMbeanExporter",
			new RootBeanDefinition(EndpointMBeanExporter.class));
	this.context.registerBeanDefinition("endpoint1",
			new RootBeanDefinition(TestEndpoint.class));
	this.context.registerBeanDefinition("endpoint2",
			new RootBeanDefinition(TestEndpoint.class));
	this.context.refresh();
	MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
	assertNotNull(mbeanExporter.getServer()
			.getMBeanInfo(getObjectName("endpoint1", this.context)));
	assertNotNull(mbeanExporter.getServer()
			.getMBeanInfo(getObjectName("endpoint2", this.context)));
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:17,代码来源:EndpointMBeanExporterTests.java

示例13: testRegistrationWithDifferentDomainAndIdentity

import org.springframework.jmx.export.MBeanExporter; //导入依赖的package包/类
@Test
public void testRegistrationWithDifferentDomainAndIdentity() throws Exception {
	Map<String, Object> properties = new HashMap<String, Object>();
	properties.put("domain", "test-domain");
	properties.put("ensureUniqueRuntimeObjectNames", true);
	this.context = new GenericApplicationContext();
	this.context.registerBeanDefinition("endpointMbeanExporter",
			new RootBeanDefinition(EndpointMBeanExporter.class, null,
					new MutablePropertyValues(properties)));
	this.context.registerBeanDefinition("endpoint1",
			new RootBeanDefinition(TestEndpoint.class));
	this.context.refresh();
	MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
	assertNotNull(mbeanExporter.getServer().getMBeanInfo(
			getObjectName("test-domain", "endpoint1", true, this.context)));
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:17,代码来源:EndpointMBeanExporterTests.java

示例14: testRegistrationWithDifferentDomainAndIdentityAndStaticNames

import org.springframework.jmx.export.MBeanExporter; //导入依赖的package包/类
@Test
public void testRegistrationWithDifferentDomainAndIdentityAndStaticNames()
		throws Exception {
	Map<String, Object> properties = new HashMap<String, Object>();
	properties.put("domain", "test-domain");
	properties.put("ensureUniqueRuntimeObjectNames", true);
	Properties staticNames = new Properties();
	staticNames.put("key1", "value1");
	staticNames.put("key2", "value2");
	properties.put("objectNameStaticProperties", staticNames);
	this.context = new GenericApplicationContext();
	this.context.registerBeanDefinition("endpointMbeanExporter",
			new RootBeanDefinition(EndpointMBeanExporter.class, null,
					new MutablePropertyValues(properties)));
	this.context.registerBeanDefinition("endpoint1",
			new RootBeanDefinition(TestEndpoint.class));
	this.context.refresh();
	MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
	assertNotNull(mbeanExporter.getServer()
			.getMBeanInfo(ObjectNameManager.getInstance(
					getObjectName("test-domain", "endpoint1", true, this.context)
							.toString() + ",key1=value1,key2=value2")));
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:24,代码来源:EndpointMBeanExporterTests.java

示例15: testRegistrationWithParentContext

import org.springframework.jmx.export.MBeanExporter; //导入依赖的package包/类
@Test
public void testRegistrationWithParentContext() throws Exception {
	this.context = new GenericApplicationContext();
	this.context.registerBeanDefinition("endpointMbeanExporter",
			new RootBeanDefinition(EndpointMBeanExporter.class));
	this.context.registerBeanDefinition("endpoint1",
			new RootBeanDefinition(TestEndpoint.class));
	GenericApplicationContext parent = new GenericApplicationContext();
	this.context.setParent(parent);
	parent.refresh();
	this.context.refresh();
	MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
	assertNotNull(mbeanExporter.getServer()
			.getMBeanInfo(getObjectName("endpoint1", this.context)));

	parent.close();
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:18,代码来源:EndpointMBeanExporterTests.java


注:本文中的org.springframework.jmx.export.MBeanExporter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。