use of org.springframework.integration.monitor.IntegrationMBeanExporter in project spring-integration by spring-projects.
the class NotificationPublishingMessageHandler method onInit.
@Override
public final void onInit() throws Exception {
Assert.isTrue(this.getBeanFactory() instanceof ListableBeanFactory, "A ListableBeanFactory is required.");
Map<String, MBeanExporter> exporters = BeanFactoryUtils.beansOfTypeIncludingAncestors((ListableBeanFactory) this.getBeanFactory(), MBeanExporter.class);
Assert.isTrue(exporters.size() > 0, "No MBeanExporter is available in the current context.");
MBeanExporter exporter = null;
for (MBeanExporter exp : exporters.values()) {
exporter = exp;
if (exporter instanceof IntegrationMBeanExporter) {
break;
}
}
if (this.notificationMapper == null) {
this.notificationMapper = new DefaultNotificationMapper(this.objectName, this.defaultNotificationType);
}
exporter.registerManagedResource(this.delegate, this.objectName);
if (this.logger.isInfoEnabled()) {
this.logger.info("Registered JMX notification publisher as MBean with ObjectName: " + this.objectName);
}
}
use of org.springframework.integration.monitor.IntegrationMBeanExporter in project spring-integration by spring-projects.
the class MBeanExporterParserTests method testMBeanExporterExists.
@Test
public void testMBeanExporterExists() {
IntegrationMBeanExporter exporter = this.context.getBean(IntegrationMBeanExporter.class);
MBeanServer server = this.context.getBean("mbs", MBeanServer.class);
Properties properties = TestUtils.getPropertyValue(exporter, "objectNameStaticProperties", Properties.class);
assertNotNull(properties);
assertEquals(2, properties.size());
assertTrue(properties.containsKey("foo"));
assertTrue(properties.containsKey("bar"));
assertEquals(server, exporter.getServer());
assertSame(context.getBean("keyNamer"), TestUtils.getPropertyValue(exporter, "namingStrategy"));
MessageChannelMetrics metrics = context.getBean("foo", MessageChannelMetrics.class);
assertTrue(metrics.isCountsEnabled());
assertFalse(metrics.isStatsEnabled());
checkCustomized(metrics);
MessageHandlerMetrics handlerMetrics = context.getBean("transformer.handler", MessageHandlerMetrics.class);
checkCustomized(handlerMetrics);
metrics = context.getBean("bar", MessageChannelMetrics.class);
assertTrue(metrics.isCountsEnabled());
assertFalse(metrics.isStatsEnabled());
metrics = context.getBean("baz", MessageChannelMetrics.class);
assertFalse(metrics.isCountsEnabled());
assertFalse(metrics.isStatsEnabled());
metrics = context.getBean("qux", MessageChannelMetrics.class);
assertFalse(metrics.isCountsEnabled());
assertFalse(metrics.isStatsEnabled());
metrics = context.getBean("fiz", MessageChannelMetrics.class);
assertTrue(metrics.isCountsEnabled());
assertTrue(metrics.isStatsEnabled());
metrics = context.getBean("buz", MessageChannelMetrics.class);
assertTrue(metrics.isCountsEnabled());
assertTrue(metrics.isStatsEnabled());
metrics = context.getBean("!excluded", MessageChannelMetrics.class);
assertFalse(metrics.isCountsEnabled());
assertFalse(metrics.isStatsEnabled());
checkCustomized(metrics);
MetricsFactory factory = context.getBean(MetricsFactory.class);
IntegrationManagementConfigurer configurer = context.getBean(IntegrationManagementConfigurer.class);
assertSame(factory, TestUtils.getPropertyValue(configurer, "metricsFactory"));
exporter.destroy();
}
use of org.springframework.integration.monitor.IntegrationMBeanExporter in project spring-integration by spring-projects.
the class IntegrationMBeanExportConfiguration method mbeanExporter.
@Bean(name = MBEAN_EXPORTER_NAME)
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public IntegrationMBeanExporter mbeanExporter() {
IntegrationMBeanExporter exporter = new IntegrationMBeanExporter();
exporter.setRegistrationPolicy(this.attributes.getEnum("registration"));
setupDomain(exporter);
setupServer(exporter);
setupComponentNamePatterns(exporter);
if (this.configurer != null) {
if (this.configurer.getDefaultCountsEnabled() == null) {
this.configurer.setDefaultCountsEnabled(true);
}
if (this.configurer.getDefaultStatsEnabled() == null) {
this.configurer.setDefaultStatsEnabled(true);
}
}
return exporter;
}
use of org.springframework.integration.monitor.IntegrationMBeanExporter in project spring-integration by spring-projects.
the class MBeanExporterHelper method postProcessAfterInitialization.
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
if (AnnotatedElementUtils.isAnnotated(AopUtils.getTargetClass(bean), IntegrationManagedResource.class.getName())) {
this.siBeanNames.add(beanName);
if (!this.mBeanExportersForExcludes.isEmpty()) {
for (MBeanExporter mBeanExporter : this.mBeanExportersForExcludes) {
mBeanExporter.addExcludedBean(beanName);
}
}
}
if (bean instanceof MBeanExporter && !(bean instanceof IntegrationMBeanExporter)) {
MBeanExporter mBeanExporter = (MBeanExporter) bean;
this.mBeanExportersForExcludes.add(mBeanExporter);
for (String siBeanName : this.siBeanNames) {
mBeanExporter.addExcludedBean(siBeanName);
}
}
return bean;
}
use of org.springframework.integration.monitor.IntegrationMBeanExporter in project spring-boot by spring-projects.
the class JmxAutoConfigurationTests method customJmxDomain.
@Test
void customJmxDomain() {
this.context = new AnnotationConfigApplicationContext();
this.context.register(CustomJmxDomainConfiguration.class, JmxAutoConfiguration.class, IntegrationAutoConfiguration.class);
this.context.refresh();
IntegrationMBeanExporter mbeanExporter = this.context.getBean(IntegrationMBeanExporter.class);
assertThat(mbeanExporter).hasFieldOrPropertyWithValue("domain", "foo.my");
}
Aggregations