javaspringspring-jmx

Spring 3.2.3 MBeanExporter doesn't honor bean property


I exported a bean via Spring MBeanExporter, this bean implements NotificationEmitter and behaves like it was a NotificationBroadcasterSupport. So it esposes the method public MBeanNotificationInfo[] getNotificationInfo(), returning a static instance of MBeanNotificationInfo[] that holds it's own notifTypes, just one string dot annotated. Loking at this bean through jconsole, instead of the configured notifTypes, I see:

ModelMBeanNotificationInfo: GENERIC ... Types: jmx.modelmbean.generic
ModelMBeanNotificationInfo: ATTRIBUTE_CHANGE ... Types: jmx.attribute.change

Also, if I subscribe notificatios via jconsole, I never see that addNotificationListener implemented method has been called. Looking at the bean code via debug, I never see any NotificationEmitter method called. While all other methods of that bean behave as expected. What does MBeanExporter do this figure?


Solution

  • The problem arise setting the property assembler of the MBeanExporter bean, in particular setting the property interfaceMappings of assembler. If the class name of the bean added to MBeanExporter and the interface name in the assembler don't math the rule interfaceName = className+"MBean" a new MBean that implements NotificationEmitter is created and regisetred into MBeanServer. Following the above rule the bean supplied with MBeanExporter is registered instead.
    This because MBeanServer while registerin, check the above rule and throws a NotCompliantMBeanException if it founds a mimatch.