JMX and MBeans with the Spring Framework

WebSphere® Application Server Version 6.1 and later supports Spring Java™ Management Extensions (JMX) MBeans.

JMX and MBeans

To use the support for Spring JMX MBeans, you must register the JMX MBeans with the MBeanServer instance of the container manager in the application server. If you do not specify a server property for the MBean, the MBeanExporter object attempts to detect an MBeanServer instance that is running. Therefore, for an application that runs in the application server, the Spring Framework would locate the MBeanServer instance of the container.

Do not use the MBeanServerFactory class to instantiate an MBeanServer instance and then inject that instance into the MBeanExporter object. Also, do not use the Spring Framework ConnectorServerFactoryBean or JMXConnectorServer classes to expose the local MBeanServer instance to clients by opening inbound JMX ports.

Registering Spring MBeans in the application server

When an MBean is registered in the application server, it is identified by a fully qualified object name, javax.management.ObjectName. For example:
WebSphere:cell=99T73GDNode01Cell,name=JmxTestBean,node=99T73GDNode01,process=server1,type=JmxTestBeanImpl 
When an MBean is deregistered, it must looked up using the same fully qualified name, rather than just the name property of the MBean. The best way to manage this to implement the org.springframework.jmx.export.naming.ObjectNamingStrategy interface. The ObjectNamingStrategy interface encapsulates the creation of ObjectName objects, and is used by the MBeanExporter class to obtain ObjectNames when beans are registered. You can add the ObjectNamingStrategy instance to the bean that you register so that the MBean is deregistered properly when the application is uninstalled. For example:
<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter"
  lazy-init="false">
  <property name="beans">
    <map> <entry key="JmxTestBean" value-ref="testBean" /> </map>
  </property>
  <property name="namingStrategy" ref="websphereNamingStrategy" />
...
</bean>

MBeans and notifications

To use notifications, it is advisable to define the object name for an MBean in full, because the MBean is identified by a fully qualified object name when it is registered in WebSphere Application Server. For example:
<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter" 
  lazy-init="false">
  <property name="beans">
    <map>
      <entry key="JmxTestBean" value-ref="testBean" />
    </map>
  </property>
  <property name="namingStrategy" ref="websphereNamingStrategy" />
  <property name="notificationListenerMappings">
    <map>
      <entry key="WebSphere:cell=99T73GDNode01Cell, name=JmxTestBean,
			node=99T73GDNode01, process=server1, type=JmxTestBeanImpl">
        <bean class="client.MBeanListener" />
      </entry>
    </map>
  </property>
</bean>
[z/OS]

Spring JMX and multicall methods in z/OS®

WebSphere Application Server Version 6.1 or later supports Spring JMX on multi-servant region servers. However, deployment options are limited because you cannot use the Spring Framework to specify platform-specific fields in the MBean descriptor. The application server defaults to the unicall strategy so that only one instance of the MBean, in a single indeterminate servant region, is asked to run a request. For some scenarios, this behavior is suitable, but more often, an application needs to declare a combination of multicall and unicall methods, and include some aggregation logic.