4 Replies Latest reply on Jan 27, 2003 10:09 AM by t1ckt0ck

    MBeanProxy design question

    t1ckt0ck

      In both implementations that I see for MBeanBroxy, in common, and jmx, it seems like you cache the MBean attributes in the Proxy/Invocation handler.

      What about in the case of a DynamicMBean that can have attributes added or removed dynamically? Say I have an "addAttribute" method exposed from a DynamicMBean, and I get a Proxy to that MBean, add an attribute, and then try to get it later on from the Proxy. It wont be there...

      Is this against the letter or spirit of the JMX spec? Are there good reasons for not just going to the server for each get attribute?

        • 1. Re: MBeanProxy design question

          DP requires a statically compiled interface. If you add/remove attributes to a dynamic mbean you would need to create a new dynamic proxy with a new static interface.

          However, the MBeanProxy in JMX package also implements the DynamicMbean interface. This means that you can type cast the same proxy to either Standard or dynamic interface.

          So if you add a new attribute to the mbean at run-time, you should be able to do something like this:


          ServiceMBean mbean = MBeanProxy.create(ServiceMBean.class);
          mbean.setFoo("foo");
          mbean.setBar("bar");

          // new attribute being added...

          DynamicMBean dmbean = (DynamicMBean)mbean;
          dmbean.setAttribute(new Attribute("MyNewAttribute", "SomeValue"));

          So you can always fall back to the non-typed dynamic invocation.

          • 2. Re: MBeanProxy design question

            Juha,

            Should we add DynamicMBean support to the
            MBeanServerInvocationHandler in jmx1.2/jboss4?

            It's not part of the spec, but it is obviously useful.

            Regards,
            Adrian

            • 3. Re: MBeanProxy design question

              sure why not, it won't affect the public object interfaces

              • 4. Re: MBeanProxy design question
                t1ckt0ck

                Juha-
                I was actually looking at the MBeanProxy from the
                jboss-3.0 tree.

                I see the DymanicMBean support in jboss-head in the

                mx/util/JMXInvocationHandler

                This is what I was looking for.

                Thanks
                Scott C