From de8ff948e7c28d3572ccbe808878bb61e0d1e38e Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Thu, 10 Mar 2011 10:02:35 -0500 Subject: [PATCH] INT-1816 chahnged NotificationPublishingMessageHandler to select the first available MBeanExporter instance --- .../jmx/NotificationPublishingMessageHandler.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spring-integration-jmx/src/main/java/org/springframework/integration/jmx/NotificationPublishingMessageHandler.java b/spring-integration-jmx/src/main/java/org/springframework/integration/jmx/NotificationPublishingMessageHandler.java index dc8a4f94c3..32e8a2619e 100644 --- a/spring-integration-jmx/src/main/java/org/springframework/integration/jmx/NotificationPublishingMessageHandler.java +++ b/spring-integration-jmx/src/main/java/org/springframework/integration/jmx/NotificationPublishingMessageHandler.java @@ -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.integration.monitor.IntegrationMBeanExporter; +import org.springframework.jmx.export.MBeanExporter; 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 exporters = BeanFactoryUtils.beansOfTypeIncludingAncestors( - (ListableBeanFactory) this.getBeanFactory(), IntegrationMBeanExporter.class); - Assert.isTrue(exporters.size() == 1, - "No unique IntegrationMBeanExporter is available in the current context (found " + + Map exporters = BeanFactoryUtils.beansOfTypeIncludingAncestors( + (ListableBeanFactory) this.getBeanFactory(), MBeanExporter.class); + Assert.isTrue(exporters.size() > 0, + "No MBeanExporter is available in the current context (found " + exporters.size() + ")."); - IntegrationMBeanExporter exporter = exporters.values().iterator().next(); + MBeanExporter exporter = exporters.values().iterator().next(); if (this.notificationMapper == null) { this.notificationMapper = new DefaultNotificationMapper(this.objectName, this.defaultNotificationType); }