Java Reference
In-Depth Information
Now you can use any JMX client tools to monitor your MBeans locally. The simplest one may be
JConsole, which comes with JDK 1.5.
Note To start JConsole, just execute the jconsole executable file (located in the bin directory of the JDK
When JConsole starts, you can see a list of JMX-enabled applications on the Local tab of the
connection window. After connecting to the replicator application, you can see your documentReplicator
MBean under the bean domain. If you want to invoke replicate() , simply click the button “ replicate .”
Exporting Spring Beans as MBeans
To export beans configured in the Spring IoC container as MBeans, you simply declare an MBeanExporter
instance and specify the beans to export, with their MBean object names as the keys.
<bean id="mbeanExporter"
<property name="beans">
<entry key="bean:name=documentReplicator"
value-ref="documentReplicator" />
The preceding configuration exports the documentReplicator bean as an MBean, under the domain
bean and with the name documentReplicator . By default, all public properties are included as attributes
and all public methods (with the exception of those from java.lang.Object ) are included as operations
in the MBean's management interface.
MBeanExporter attempts to locate an MBean server instance and register your MBeans with it
implicitly. If your application is running in an environment that provides an MBean server (e.g., most
Java EE application servers), MBeanExporter will be able to locate this MBean server instance.
However, in an environment with no MBean server available, you have to create one explicitly using
Spring's MBeanServerFactoryBean . To make your application portable to different runtime environments,
you should enable the locateExistingServerIfPossible property so that this factory bean will create an
MBean server only if none is available.
Note JDK 1.5 will create an MBean server for the first time when you locate it. So, if you're using JDK 1.5 or
above, you needn't create an MBean server explicitly.
<bean id="mbeanServer"
<property name="locateExistingServerIfPossible" value="true" />
Search WWH ::

Custom Search