-
1. Re: MBean with plugins
dimitris Jun 15, 2005 2:25 PM (in response to jimdwyer)A common pattern is to have an attribute of type String containing the full class name of a class implementing some interface of yours that you instantiate in the mbean.
Just be carefull when loading the class:
http://wiki.jboss.org/wiki/Wiki.jsp?page=HowCanIDynamicallyLoadClassesWithinAnMBean
If you want to have many of them, why not using an attribute of type String[]?
In any case, no need to change any dtds, whatsoever... -
2. Re: MBean with plugins
jimdwyer Jun 15, 2005 2:32 PM (in response to jimdwyer)Cool. I will check it out. Editing the DTD was a last resort and not something I really wanted to do.
-
3. Re: MBean with plugins
jimdwyer Jun 15, 2005 2:59 PM (in response to jimdwyer)dimitris,
The plugins are not only classnames but also the class arguments. Basically I want to be able to instantiate classes using a specific constructor. All passed in through the -service.xml file.
Jim -
4. Re: MBean with plugins
dimitris Jun 15, 2005 5:24 PM (in response to jimdwyer)Then you'll have a problem. I guess there are 3 solutions.
1) Make the plugins mbeans (or xmbeans) themselves, so you can create them using any constructor (the -service.xml syntax permits this). Then make the central mbean have a dependency list with their ObjectNames:<mbean code="myBean" name="domain:name=x"> <depends-list optional-attribute-name="ObjectNameList"> <depends-list-element>domain:name=y</depends-list-element> <depends-list-element>domain:name=z</depends-list-element> </depends-list> </mbean>
This has the advantage of the plugins being manageable as well.
2) Have an attribute of type org.w3c.dom.Element that supports your own arbitrary format for specifying classes and constructors parameters. You'll then have to parce that dom Element and do whatever (instantiate and initialize the mbean. As an example see how the SubscriptionList attribute is parsed in class org.jboss.system.ListenerServiceMBeanSupport, or look at how org.jboss.system.ServiceConfiguration is implemented.
3) Wait a few months for the new JBoss MicroContainer that will let you do (1) but without actually the mbean requirement. -
5. Re: MBean with plugins
jimdwyer Jun 16, 2005 11:16 AM (in response to jimdwyer)Sounds like I need a MagicBean!
-
6. Re: MBean with plugins
opiegai Jun 22, 2005 3:11 AM (in response to jimdwyer)The plugins could be MBeans as well and register with the Mbean using the plugins.
You would need a register/deregister fuction like this:
register( IPlugin p );
deregister( IPlugin p );
The plugin MBean would call these functions and pass itself.