PDA

View Full Version : Full example of JMX in spring


Anonymous
Aug 25th, 2005, 10:22 AM
Hi,

Can anyone tell me what else I need to do apart from the description from
http://www.springframework.org/docs/reference/jmx.html, as I cannot see my bean in jconsole, although the program runs.

It seems the code I added in XML file doesn't create the server at all.

Do I need to code any for Mbean server part? if so can any one post a simple example for me, thanks.

Anonymous
Aug 25th, 2005, 10:27 AM
Sorry, I try to get a stand alone server with jdk 1.5.

Anonymous
Aug 29th, 2005, 11:53 AM
So, why does the JConsole not show the Mbean when we use the MBeanServerFactoryBean to our configuration as shown in 18.2.1 of the JMX document. Java 1.5 VM has MBeanServer 1 : com.sun.jmx.mbeanserver.JmxMBeanServer server in there.
Thanks.

Anonymous
Oct 21st, 2005, 11:22 AM
Spring configuration is only half part of the solution.
You have also to instantiate the objects defined into the configuration.

Example:


<beans>
<bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactory Bean"/>

<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
<property name="beans">
<map>
<entry key="bean:name=test" value-ref="testBean"/>
<map>
</property>

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

<bean id="serverConnector" class="org.springframework.jmx.support.ConnectorServerFac toryBean">
<property name="objectName" value="connector:name=rmi"/>
<property name="serviceUrl"
value="service:jmx:rmi://localhost/jndi/rmi://localhost:1099/myconnector"/>

<property name="threaded" value="true"/>
<property name="daemon" value="true"/>
<property name="server">
<ref local="mbeanServer"/>
</property>
</bean>

<bean id="registry" class="org.springframework.remoting.rmi.RmiRegistryFactor yBean">
<property name="port" value="1099"/>
</bean>

...


In your application:


public static void main(String[] args) {

...
Object serverConnector=getFactory().getBean("serverConnector");
Object exporter=getFactory().getBean("exporter");
...
}


That's All!

(As in test\org\springframework\jmx\export\MBeanExporterT ests.java)

Costin Leau
Oct 22nd, 2005, 05:42 PM
You have a working example inside the spring distribution.