INT-1816 added support for multiple non-conflicting mbean exporters

This commit is contained in:
Oleg Zhurakousky
2011-03-09 12:49:04 -05:00
parent 0b5f3b20e4
commit 1b3e7ce6e9
3 changed files with 17 additions and 11 deletions

View File

@@ -29,7 +29,7 @@ import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.integration.Message;
import org.springframework.integration.handler.AbstractMessageHandler;
import org.springframework.integration.mapping.OutboundMessageMapper;
import org.springframework.jmx.export.MBeanExporter;
import org.springframework.integration.monitor.IntegrationMBeanExporter;
import org.springframework.jmx.export.annotation.ManagedResource;
import org.springframework.jmx.export.notification.NotificationPublisher;
import org.springframework.jmx.export.notification.NotificationPublisherAware;
@@ -90,12 +90,12 @@ public class NotificationPublishingMessageHandler extends AbstractMessageHandler
@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);
Map<String, IntegrationMBeanExporter> exporters = BeanFactoryUtils.beansOfTypeIncludingAncestors(
(ListableBeanFactory) this.getBeanFactory(), IntegrationMBeanExporter.class);
Assert.isTrue(exporters.size() == 1,
"No unique MBeanExporter is available in the current context (found " +
"No unique IntegrationMBeanExporter is available in the current context (found " +
exporters.size() + ").");
MBeanExporter exporter = exporters.values().iterator().next();
IntegrationMBeanExporter exporter = exporters.values().iterator().next();
if (this.notificationMapper == null) {
this.notificationMapper = new DefaultNotificationMapper(this.objectName, this.defaultNotificationType);
}