|
From: Michael S. <mi...@sc...> - 2005-02-22 21:48:03
|
On Tuesday 22 February 2005 21:26, Scott Battaglia wrote:
> Okay, I'll look for them after the 1.1.5 release then! In the mean
> time are any of the test cases a good kind of guide to follow? I'm
> not too familar with JMX so I'm learning JMX and trying to figure out
> the Spring support at the same time (probably not a good
> combination).
If all you want to do is expose a Spring bean as an MBean it's actually=20
pretty easy and doesn't require any code.
Create an MBeanServer registered as a bean
=A0 <bean id=3D"mbeanserver"
=A0 =A0class=3D"org.springframework.jmx.factory.MBeanServerFactoryBean">
=A0 =A0 <property name=3D"defaultDomain"><value>MyDomain</value></propert=
y>
=A0 </bean>
Wrap an MBean adapter around my repositorymanager bean (not shown),=20
which is a completely ordinary java object. In this case, public=20
methods are exposed as attributes/operations. Alternatively, metadata =A0
can be used.
=A0 <bean id=3D"mbeanadapter"
=A0 =A0class=3D"org.springframework.jmx.JmxMBeanAdapter">
=A0 =A0 <property name=3D"server"><ref local=3D"mbeanserver"/></property>
=A0 =A0 <property name=3D"beans">
=A0 =A0 =A0 <map>
=A0 =A0 =A0 =A0 <entry key=3D"MyDomain:id=3DRepository">
=A0 =A0 =A0 =A0 =A0 <ref bean=3D"repositorymanager"/>
=A0 =A0 =A0 =A0 </entry>
=A0 =A0 =A0 </map>
=A0 =A0 </property>
=A0 </bean>
Create a connector listening, by default, on=20
service:jmx:jmxmp://localhost:9876 (this requires=20
jmxremote_optional.jar)
<bean id=3D"jmxconnector"
class=3D"org.springframework.jmx.support.ConnectorServerFactoryBean">
<property name=3D"server">
<ref local=3D"mbeanserver" />
</property>
<!-- This is the default URL anyway -->
<property name=3D"serviceUrl">
<value>service:jmx:jmxmp://localhost:9876</value>
</property>
<property name=3D"threaded">
<value>true</value>
</property>
<!-- Ensure the connector thread doesn't keep the
servlet container running -->
<property name=3D"daemon">
<value>true</value>
</property>
</bean>
HTH,
Michael
--=20
Michael Schuerig Face reality and stare it down
mailto:mi...@sc... --Jethro Tull, Silver River Turning
http://www.schuerig.de/michael/
|