Creating an MBeanServer by R4R Team

Creating an MBeanServer:-

The Bean configuration assumes that the application is running in an environment that has one MBeanServer already running. In this case, Spring will attempt to locate the running MBeanServer and register your beans with that server. This behavior is useful when your application is running inside a container such as Tomcat or IBM WebSphere that has its own MBeanServer.

However, this approach is  no use in a standalone environment, or when running inside a container that does not provide an MBeanServer. To address this you can create an MBeanServer instance declaratively by adding an instance of the org.springframework.jmx.support.MBeanServerFactoryBean class to your configuration. You can also ensure that a specific MBeanServer is used by setting the value of the MBeanExporter's server property to the MBeanServer value returned by an MBeanServerFactoryBean.

<beans>

<bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean"/>

<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">

<property name="beans">

<map>

<entry key="bean:name=testBean1" value-ref="testBean"/>

</map>

</property>

<property name="server" ref="mbeanServer"/>

</bean>

<bean id="testBean" class="org.springframework.jmx.JmxTestBean">

<property name="name" value="Test"/>

<property name="age" value="60"/>

</bean>

</beans>

Here an instance of MBeanServer is created by the MBeanServerFactoryBean and is supplied to the MBeanExporter via the server property.

Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!