how to register NotificationListener w/o MBeanExporter
I have a remote MBean that we registered without using Spring (ie without MBeanExporter).
Locally, I would like to register a NotificationListener - reference docs suggest that is possible. However, example given uses MBeanExporter to register a NotificationListener. Could someone please point an example of how to register a listener w/out using an exporter?
I did the following to no effect:
Code:
<bean id="masterStatsNotificationListenerHolder" class="org.springframework.jmx.export.NotificationListenerBean">
<property name="notificationListener" ref="masterMBeanNotificationListener"/>
<property name="mappedObjectName" value="Hibernate:type=statistics,dataSource=masterDataSource"/>
</bean>
<bean id="masterMBeanNotificationListener" class="com.doppelganger.test.EnvmanagerStatisticsServiceMBeanNotificationListener"/>
import javax.management.Notification;
import javax.management.NotificationListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author nikita
*/
public class EnvmanagerStatisticsServiceMBeanNotificationListener
implements NotificationListener {
private static final Logger LOG = LoggerFactory.getLogger(EnvmanagerStatisticsServiceMBeanNotificationListener.class);
public void handleNotification(Notification notification, Object handback) {
LOG.info("notification=" + notification);
LOG.info("handback=" + handback);
}
}
Use MBeanExporter to register your listener.
The following works with the help of MBeanExporter.
<bean name="exporter" class="org.springframework.jmx.export.MBeanExporte r">
<property name="server" ref="yourserver"/>
<property name="registrationBehaviorName" value="REGISTRATION_REPLACE_EXISTING"/>
<property name="beans">
<map/>
</property>
<property name="notificationListenerMappings">
<map>
<entry key="your MBean">
<bean class="yourListenerClass" />
</entry>
</map>
</property>
</bean>
Good luck.
Quote:
Originally Posted by
dukehoops
I have a remote MBean that we registered without using Spring (ie without MBeanExporter).
Locally, I would like to register a NotificationListener - reference docs suggest that is possible. However, example given uses MBeanExporter to register a NotificationListener. Could someone please point an example of how to register a listener w/out using an exporter?
I did the following to no effect:
Code:
<bean id="masterStatsNotificationListenerHolder" class="org.springframework.jmx.export.NotificationListenerBean">
<property name="notificationListener" ref="masterMBeanNotificationListener"/>
<property name="mappedObjectName" value="Hibernate:type=statistics,dataSource=masterDataSource"/>
</bean>
<bean id="masterMBeanNotificationListener" class="com.doppelganger.test.EnvmanagerStatisticsServiceMBeanNotificationListener"/>
import javax.management.Notification;
import javax.management.NotificationListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author nikita
*/
public class EnvmanagerStatisticsServiceMBeanNotificationListener
implements NotificationListener {
private static final Logger LOG = LoggerFactory.getLogger(EnvmanagerStatisticsServiceMBeanNotificationListener.class);
public void handleNotification(Notification notification, Object handback) {
LOG.info("notification=" + notification);
LOG.info("handback=" + handback);
}
}