|
From: Rob B. <rob...@ve...> - 2003-12-03 14:55:36
|
> > There are some similarities between JMX and Spring. The JMX spec. > defines a MLET service, a class capable of loading JMX components > (MBean) based on the XML-like file format. The XML format is usually too different between different JMX Kernel implementations to get any sort of portability at all. This is bad if you are building something you want to deploy in multiple locations (like JBoss & Websphere 5.0) because you would have to maintain a different XML file for each. > I have always thought that Spring could play well with JMX, creating > MBeans in the same manner as it creates "plain" beans. There are two > things to do: > > 1) Detect beans that are also mbeans and register them with the > MBeanServer. This should be very easy to do. Spring already > supports bean initialization, we have a name - there is only > call to mserver instance missing. Of course, there are more > complex things to deal with but not much. Only if you have to do something special.. There is actually a much better way in my opinion -- see below. > 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, and provide portability too. The JMX spec requires a JMX kernel to provide a "model" mbean - the RequiredModelMBean. The RequiredModelMBean has a no-arg constructor (RequiredModelMBean()) and also has JavaBean style setters for most pieces of the required data. (Does Spring support passing two fields to a setter?) Also since Spring supports constructors now you should be able to "construct" a ModelMBean using only Spring. OR, if Spring cannot currently do this directly (because it cannot pass two fields to a setter) building a generic Spring ModelMBean factory shouldn't be too tough. Then this ModelMBean factory could be used to construct any ModelMBean you need. ModelMBeans are pretty cool because you can have them invoke arbitrary getters / setters / functions on your java code. So once the Generic ModelMBean factory is built (if it even has to be) you can use it to "construct" a JMX MBean at startup using Spring, and have this MBean invoke operations on your standard javabeans. This allows you to pretty much expose any operation or property of your beans via JMX without having to write new code. Additional JMX MBeans or capabilities is as easy as changing your spring config. Also, since the RequiredModelMBean is available in EVERY JMX kernel, and it's API is set by the JMX spec, you have true portability. Not bad eh. I haven't done this yet, but it is how I thought the problem could be approached. Now to complete the circle all you need is to persist the modifications your JMX calls make. Thus the suggestions I made earlier on the list about storing configuration in a database, and then having Spring reload. (see the archives) Then instead of having the JMX ModelMBean invoke operations on the setters, you have it invoke operations on the DB via DAO. Then reload spring and all changes take effect. (of course your app has to be designed to support reload). You can still "wire up" your javabeans to obtain read only performance type information. Springs support for events in the application context would be helpful here. (P.S. Spring needs more work in the event handling area to be more robust - threading issues are pretty much ignored in the current implementation.) Hope this helps out. When I get some spare time I hope to do a lot of these things with Spring - and contribute some patches too. But that is going to have to wait a little while. :( Later Rob |
|
From: Ivan R. <iv...@we...> - 2003-12-03 15:23:46
|
Rob Butler wrote: >>There are some similarities between JMX and Spring. The JMX spec. >>defines a MLET service, a class capable of loading JMX components >>(MBean) based on the XML-like file format. > > The XML format is usually too different between different JMX Kernel > implementations to get any sort of portability at all. Is it? Because MLET is part of the standard spec. But that's not important as MLET is not good enough anyway. >>I have always thought that Spring could play well with JMX, creating >>MBeans in the same manner as it creates "plain" beans. There are two >>things to do: >> >>1) Detect beans that are also mbeans and register them with the >> MBeanServer. This should be very easy to do. Spring already >> supports bean initialization, we have a name - there is only >> call to mserver instance missing. Of course, there are more >> complex things to deal with but not much. > > > Only if you have to do something special.. There is actually a > much better way in my opinion -- see below. I agree what you've said below but you still need to support static mbeans. It would make no sense to have to supply additional configuration for a static mbean :) >>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, and > provide portability too. Yes, that is great. The only drawback would be that it will complicate the configuration file further. Perhaps Spring should support another configuration file with a different syntax. And this configuration file would use bean names to reference beans and then specify which attributes and methods should be exposed to JMX. > Hope this helps out. When I get some spare time I hope to do a lot > of these things with Spring - and contribute some patches too. But > that is going to have to wait a little while. :( Same here. Actually I am just starting with an JMX project but I think I will use the MX4J syntax for the time being (I don't need JMX implementation portability). I am on a tight deadline. -- ModSecurity (http://www.modsecurity.org) [ Open source IDS for Web applications ] |
|
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 ] |
|
From: Rob B. <rob...@ve...> - 2003-12-06 17:22:52
|
Looks pretty good initially. I'll take a better look at the links later and have more feedback then. Later Rob ----- Original Message ----- From: "Ivan Ristic" <iv...@we...> To: <spr...@li...> Sent: Saturday, December 06, 2003 12:10 PM Subject: Re: [Springframework-developer] Spring & JMX > > >>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 ] > > > > ------------------------------------------------------- > This SF.net email is sponsored by: IBM Linux Tutorials. > Become an expert in LINUX or just sharpen your skills. Sign up for IBM's > Free Linux Tutorials. Learn everything from the bash shell to sys admin. > Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer |
|
From: Colin S. <col...@ex...> - 2003-12-06 17:34:50
|
I have some code (donated by a friend), which can automatically expose beans in a Spring context via BeanPostProcessor. It's pretty simplistic, but I can also post that here if anybody wants to look at it... Rob Butler wrote: >Looks pretty good initially. I'll take a better look at the links later and >have more feedback then. > >Later >Rob >----- Original Message ----- >From: "Ivan Ristic" <iv...@we...> >To: <spr...@li...> >Sent: Saturday, December 06, 2003 12:10 PM >Subject: Re: [Springframework-developer] Spring & JMX > > > > >>>>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 ] >> >> >> >>------------------------------------------------------- >>This SF.net email is sponsored by: IBM Linux Tutorials. >>Become an expert in LINUX or just sharpen your skills. Sign up for IBM's >>Free Linux Tutorials. Learn everything from the bash shell to sys admin. >>Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click >>_______________________________________________ >>Springframework-developer mailing list >>Spr...@li... >>https://lists.sourceforge.net/lists/listinfo/springframework-developer >> >> > > > >------------------------------------------------------- >This SF.net email is sponsored by: IBM Linux Tutorials. >Become an expert in LINUX or just sharpen your skills. Sign up for IBM's >Free Linux Tutorials. Learn everything from the bash shell to sys admin. >Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click >_______________________________________________ >Springframework-developer mailing list >Spr...@li... >https://lists.sourceforge.net/lists/listinfo/springframework-developer > > |
|
From: Rod J. <rod...@in...> - 2003-12-06 17:37:50
|
Colin, Why don't you check it into the sandbox? I've also been thinking about a contrib area...it would be good to have some way of sharing code that may or may not ever make it into Spring proper--for example, code useful to a lot of users, but not really a part of the framework. Regards, Rod ----- Original Message ----- From: "Colin Sampaleanu" <col...@ex...> To: <spr...@li...> Sent: Saturday, December 06, 2003 5:35 PM Subject: Re: [Springframework-developer] Spring & JMX > I have some code (donated by a friend), which can automatically expose > beans in a Spring context via BeanPostProcessor. It's pretty simplistic, > but I can also post that here if anybody wants to look at it... > > > Rob Butler wrote: > > >Looks pretty good initially. I'll take a better look at the links later and > >have more feedback then. > > > >Later > >Rob > >----- Original Message ----- > >From: "Ivan Ristic" <iv...@we...> > >To: <spr...@li...> > >Sent: Saturday, December 06, 2003 12:10 PM > >Subject: Re: [Springframework-developer] Spring & JMX > > > > > > > > > >>>>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 ] > >> > >> > >> > >>------------------------------------------------------- > >>This SF.net email is sponsored by: IBM Linux Tutorials. > >>Become an expert in LINUX or just sharpen your skills. Sign up for IBM's > >>Free Linux Tutorials. Learn everything from the bash shell to sys admin. > >>Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click > >>_______________________________________________ > >>Springframework-developer mailing list > >>Spr...@li... > >>https://lists.sourceforge.net/lists/listinfo/springframework-developer > >> > >> > > > > > > > >------------------------------------------------------- > >This SF.net email is sponsored by: IBM Linux Tutorials. > >Become an expert in LINUX or just sharpen your skills. Sign up for IBM's > >Free Linux Tutorials. Learn everything from the bash shell to sys admin. > >Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click > >_______________________________________________ > >Springframework-developer mailing list > >Spr...@li... > >https://lists.sourceforge.net/lists/listinfo/springframework-developer > > > > > > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: IBM Linux Tutorials. > Become an expert in LINUX or just sharpen your skills. Sign up for IBM's > Free Linux Tutorials. Learn everything from the bash shell to sys admin. > Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer > |
|
From: Mark P. <Mar...@Co...> - 2003-12-06 19:13:50
|
Hi, We are using the commons-modeler on a current project, no problems as far as that package is concerned, so I think it would be a good foundation use. - Mark > Colin, > > Why don't you check it into the sandbox? > > I've also been thinking about a contrib area...it would be good to have > some > way of sharing code that may or may not ever make it into Spring > proper--for > example, code useful to a lot of users, but not really a part of the > framework. > > Regards, > Rod > > ----- Original Message ----- > From: "Colin Sampaleanu" <col...@ex...> > To: <spr...@li...> > Sent: Saturday, December 06, 2003 5:35 PM > Subject: Re: [Springframework-developer] Spring & JMX > > >> I have some code (donated by a friend), which can automatically expose >> beans in a Spring context via BeanPostProcessor. It's pretty simplistic, >> but I can also post that here if anybody wants to look at it... >> >> >> Rob Butler wrote: >> >> >Looks pretty good initially. I'll take a better look at the links >> later > and >> >have more feedback then. >> > >> >Later >> >Rob >> >----- Original Message ----- >> >From: "Ivan Ristic" <iv...@we...> >> >To: <spr...@li...> >> >Sent: Saturday, December 06, 2003 12:10 PM >> >Subject: Re: [Springframework-developer] Spring & JMX >> > >> > >> > >> > >> >>>>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 ] >> >> >> >> >> >> >> >>------------------------------------------------------- >> >>This SF.net email is sponsored by: IBM Linux Tutorials. >> >>Become an expert in LINUX or just sharpen your skills. Sign up for > IBM's >> >>Free Linux Tutorials. Learn everything from the bash shell to sys > admin. >> >>Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click >> >>_______________________________________________ >> >>Springframework-developer mailing list >> >>Spr...@li... >> >>https://lists.sourceforge.net/lists/listinfo/springframework-developer >> >> >> >> >> > >> > >> > >> >------------------------------------------------------- >> >This SF.net email is sponsored by: IBM Linux Tutorials. >> >Become an expert in LINUX or just sharpen your skills. Sign up for >> IBM's >> >Free Linux Tutorials. Learn everything from the bash shell to sys >> admin. >> >Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click >> >_______________________________________________ >> >Springframework-developer mailing list >> >Spr...@li... >> >https://lists.sourceforge.net/lists/listinfo/springframework-developer >> > >> > >> >> >> >> >> >> ------------------------------------------------------- >> This SF.net email is sponsored by: IBM Linux Tutorials. >> Become an expert in LINUX or just sharpen your skills. Sign up for >> IBM's >> Free Linux Tutorials. Learn everything from the bash shell to sys >> admin. >> Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click >> _______________________________________________ >> Springframework-developer mailing list >> Spr...@li... >> https://lists.sourceforge.net/lists/listinfo/springframework-developer >> > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: IBM Linux Tutorials. > Become an expert in LINUX or just sharpen your skills. Sign up for IBM's > Free Linux Tutorials. Learn everything from the bash shell to sys admin. > Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer > |
|
From: Ivan R. <iv...@we...> - 2003-12-06 19:20:10
Attachments:
AbstractJMXBridge.java
MyJMXBridge.java
|
Rod Johnson wrote: > Colin, > > Why don't you check it into the sandbox? > > I've also been thinking about a contrib area...it would be good to have some > way of sharing code that may or may not ever make it into Spring proper--for > example, code useful to a lot of users, but not really a part of the > framework. Here's my code (gave me a nice excuse to learn how BeanPostProcessor interface works). AbstractJMXBridge is the class to look at. It will first try to find a mapping by name, then by class. If that fails it will attempt to register the bean directly (that will succeed only if the bean implements one of the JMX interfaces). MyJMXBridge is an example implementation that uses the MX4J MBeanServer. -- ModSecurity (http://www.modsecurity.org) [ Open source IDS for Web applications ] |