Network Deployment (Distributed operating systems), v8.0 > Applications > Spring applications > Spring Framework


JMX and MBeans with the Spring Framework

WAS v6.1 and later supports Spring JMX MBeans.


JMX and MBeans

To use the support for Spring JMX MBeans, 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.


Register 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. We 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 WAS. 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>

Spring Framework
Spring Documentation Concept topic

+

Search Tips   |   Advanced Search