|
From: Ivan R. <iv...@we...> - 2003-12-06 17:08:51
|
>>2) Expose normal beans as JMX MBeans. This would allow any bean to >> be manipulated through the JMX protocol. This is also easy to do >> although there is more work involved. > > Actually, I think this can be a lot less work if done right It is a lot easier than I thought: There is an Jakarta Commons package called Modeler (http://jakarta.apache.org/commons/modeler.html) that uses an XML definition file and exposes plain beans as managed beans. This is how it looks like: ----------------- <mbeans-descriptors> <mbean name="redBean" description="Red Bean" type="Bean"> <attribute name="color" description="The color of the bean" type="java.lang.String" /> </mbean> <!-- the same class but expose two attributes instead of one --> <mbean name="bean" description="Blue Bean" type="Bean"> <attribute name="color" description="The color of the bean" type="java.lang.String" /> <attribute name="name" description="The name of the bean" type="java.lang.String" /> </mbean> </mbeans-descriptors> ----------------- Therefore all one needs to do is: 1) Prepare an XML definition file specifying for each bean which attributes and methods to expose. 2) List the beans in an application context, and create managed beans using the definition file. Here's a link to the ONLamp article explaining how the Modeler is used: http://www.onjava.com/pub/a/onjava/2003/07/09/commons.html This Eclipse JMX plugin seems to work all right http://www.xtremej.com/ and you can use it to remotely connect to the exposed beans, get/set attributes and invoke methods. Spring could supply an abstract helper class for JMX integration (AbstractJMXBridge). The class would need to be subclassed to provide a method to create the JMX-related stuff (create the MBeanServer, and configure it). Thoughts? -- ModSecurity (http://www.modsecurity.org) [ Open source IDS for Web applications ] |