Results 1 to 3 of 3

Thread: Nested MBeans

  1. #1
    Join Date
    Jan 2006
    Posts
    2

    Default Nested MBeans

    I have two bean BeanA and BeanB. BeanA has a BeanB as its member variable.
    public class BeanA{
    private BeanB b

    pubilc BeanB getBeanB(){
    return b;
    }

    public void setBeanB(BeanB b){
    this.b = b;
    }
    }

    Both of them are registered as MBeans in configuration file like this

    <?xml version="1.0" encoding="UTF-8"?>

    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

    <!-- Contains beans which needs to be exposed as MBeans by spring framework -->
    <beans>

    <bean id="exporter" class="org.springframework.jmx.export.MBeanExporte r">
    <property name="beans">
    <map>
    <entry key="bean:name=MBeanA">
    <ref local="beanA"/>
    </entry>
    <entry key="bean:name=MBeanB">
    <ref local="beanB"/>
    </entry>
    </map>
    </property>
    </bean>
    <!-- User defined beans -->
    <bean id="beanA" class="BeanA">
    <constructor-arg>
    <ref bean="beanB"/>
    </constructor-arg>
    </bean>

    <bean id="beanB" class="BeanB"/>
    </beans>

    How can i get beanB as an MBean inside MBeanA so that when i view MBeanA in jmx console i see beanB as an nested MBean inside MBeanA.

    Thanks in advance
    Sameer Garg.

  2. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    The exporter creates the mbeans on the fly based on different methods like interfaces, getter/setters and so on. In order to nest mbeanB inside mbeanA the getter for B inside mbeanA would have to be replaced so it will return not B, but the mbean itself.
    Considering that the mbean invokes the methods on the actual object(bean) you'll actually going to replace the 'real' getter.

    If your mbeanA will return mbeanB on getB(), who will you be able to get the real B?
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  3. #3
    Join Date
    Aug 2004
    Location
    Southampton, UK
    Posts
    826

    Default

    This is something of an issue with JMX right now and it will be resolved with the inclusion of MXBeans in the next specification release.

    Rob
    Rob Harrop
    Lead Engineer, dm Server
    SpringSource
    http://www.springsource.com

    Co-Author - Pro Spring

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •