Hi Alasdair, Thanks again for the reply! The snippet below - will it automatically instrument the bean ans register with the available JMX server?
I mean I do not have to make the SampleBean implement an interface with name ending MBean? If yes it looks similar to the JNDI extender pattern. Please confirm! Also what are all the Blue Print Bundles I need to have?. And also I cannot connect to Felix JMX server from JConsole. Any ideas? Thanks Matt On Sat, Aug 6, 2011 at 2:50 AM, Alasdair Nottingham <[email protected]> wrote: > Hi, > > there is a hole in the documentation on the JMX whiteboard, i.e. we don't > have any, although it is now on the mailing list. > > The example from Felix can be rewritten as: > > <bean id="myMBean" class="SampleBean"/> > <service interface="SampleMBean" ref="myMBean"> > <service-properties> > <entry key="jmx.objectname" value="domain:name=sample" /> > </service-properties> > </service > > I'm not familiar with the MBeanExporter, but it does seem to me that it > will register MBeans with the MBeanServer so it does not fit well with JMX > Whiteboard model. Another problem is a lot of these spring classes rely on > protected methods to build objects which blueprint doesn't support (it > requires them to be public). That said I expect the sample you have provided > could be made to work if the xml were blueprint compliant. To make it > blueprint compliant you should wrap the snippet below in a <blueprint > xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"> element and remove > lazy-init="false". > > Alasdair > > > On 4 August 2011 21:17, Matt Madhavan <[email protected]> wrote: > >> Hi Am and Chetan, >> Thanks for the reply. Can you guys send me some more examples or pointers >> to some other examples? >> >> Also the following config in spring (no springDM) will expose any POJO as >> a JMX MBean. >> <bean id="sample" class="com.xxxx.*SampleBean*"> >> <property name="beanProp" ref="whatEver" /> >> </bean> >> >> <bean id="exporter" class="org.springframework.jmx.export.MBeanExporter" >> lazy-init="false"> >> <property name="beans"> >> <map> >> <entry key="bean:name=sample" value-ref="*sample*" /> >> </map> >> </property> >> </bean> >> >> It essentially replaces the first part of code sample you sent as below >> *class SampleBean implements SampleMBean { ... }* >> >> Now I wonder how do I modify the xml code fragment you sent as below: >> bundleContext.registerService(Object.class, >> new SampleBean(), >> new Hashtable() {{ >> put("jmx.objectname", "domain:name=sample");}}); >> >> >> I wonder if can marry the SpringJMX exporter exporting an JMX instrumented >> class and creating an OSGi service using Aries JMX while board. >> >> Also, is there any documentation on Aries JMX whiteboard? >> >> Thanks >> Matt >> >> On Wed, Aug 3, 2011 at 2:35 AM, Felix Meschberger <[email protected]>wrote: >> >>> Hi, >>> >>> Am Dienstag, den 02.08.2011, 18:07 -0500 schrieb Matt Madhavan: >>> > Hello, >>> > I want to export one of bundle (service) as a JMX service. It was so >>> > easy to do so in SpringDM. I'm sure we have something similar in >>> > Aries. But I cannot find any documentation on it at all. >>> > >>> > >>> > I have see the Aries(BluePrint) JMX extender bundles. But not sure how >>> > to use them. >>> > >>> > >>> > Can some one point me to the right documentation/sample please? >>> >>> There are basically two options: >>> >>> * Get the MBeanServer service and register your MBean therewith >>> * Register your MBean as a service have the Aries JMX Whiteboard >>> support handle the rest. >>> >>> I prefer the latter since it is more like OSGi and easier to do. Just >>> ensure your MBean implements some MBean interface (mostly extending from >>> DynamicMBean) and have a jmx.objectname service registration property >>> defining the MBean name. >>> >>> The jmx.objectname service registration property is mandatory and >>> identifies the service to be an MBean. If the property is empty, the >>> service must implement the MBeanRegistration interface to provide the >>> ObjectName during registration. The actual MBean interface implemented >>> by the service is found by introspection. >>> >>> Thus an extremely simple sample would be: >>> >>> class SampleBean implements SampleMBean { ... } >>> bundleContext.registerService(Object.class, >>> new SampleBean(), >>> new Hashtable() {{ >>> put("jmx.objectname", "domain:name=sample");}}); >>> >>> Regards >>> Felix >>> >>> > >>> > >>> > Thanks in advance! >>> > >>> > >>> > Matt >>> > >>> > >>> > >>> > >>> >>> >>> >> > > > -- > Alasdair Nottingham > [email protected] >
