|
From: jacksu <jac...@gm...> - 2007-06-21 22:30:31
|
I think I must done something wrong, I am trying to hook JMX to
spring, but appears spring framework just ignore the JMX exporter
class totally, unless I call getBean of that exporter class
explicitly.
Would anyone here could give me some hint? Thanks.
public class Main {
public static void main(String args[]) throws Exception {
BeanFactory factory =
new XmlBeanFactory(new ClassPathResource("com/jacktest/
beans.xml"));
// if uncomment the following line. I could see my testbean in
jconsole. but if without this line, jconsole couldn't
// find my testbean.
// factory.getBean("exporter");
TestBean tst = (TestBean)factory.getBean("testBean");
}
}
This is the bean definition:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
<bean id="testBean" class="com.jacktest.TestBean">
<property name="firstName" value="Jack"/>
</bean>
<bean id="mbeanServer"
class="org.springframework.jmx.support.MBeanServerFactoryBean" />
<!-- this bean must not be lazily initialized if the exporting is
to happen -->
<bean id="explorerBean"
class="org.springframework.jmx.export.MBeanExporter">
<property name="beans">
<map>
<entry key="bean:name=testBean" value-ref="testBean"/>
</map>
</property>
</bean>
</beans>
And my command line has flag: -Dcom.sun.management.jmxremote.
Thanks in advance.
-- Jack
|