3 Replies Latest reply on Feb 10, 2005 11:50 AM by Kabir Khan

    Generate MBeanInfo from arbitrary interface

    Kabir Khan Master

      Hi Adrian,

      I'm looking at the @Management stuff for ejb3. It is the new interface for EJB3 allowing us to register beans in JMX. I need to generate MBeanInfo from the @Management annotated interface.

      There is some code in StandardMetadata that does this, but it isn't reusable for my purposes since it wants the class/interface naming to follow the standard Mbean convention, i.e. class XXX implements XXXMBean
      Are you aware of any reusable code? Refactoring StandardMetadata is not really an option at this stage for EJB3 Preview 3 to run on JBoss 4.0.1.



        • 1. Re: Generate MBeanInfo from arbitrary interface
          Adrian Brock Master

          If you don't want to follow StandardMBean semantics
          cf. javax.management.StandardMBean rather than StandardMetadata
          you have to use a DynamicMBean or ModelMBean (which is what Bill's says
          Something like the StandardMBean implementation could be used as
          a starting point for generating MBeanInfo from annotations rather than an interface.

          ModelMBean approach:

          RequiredModelMBean rmm = new RequiredModelMBean();
          mbeanServer.registerMBean(rmm, objectName);

          I have my reservations about the approach depending upon what you are
          trying to achieve.

          1) If this is @Service you are essentially defining an EJB singleton which is ok.

          2) It does not make sense to me to define management on normal ejb instances.
          EJB instances have a fleeting existance so registering them with the MBeanServer
          is ludricous. Also, imagine creating an MBean for every row in the database.

          3) Why would you define a management interface that is not implemented
          by the management singleton? It seems overly complex to use annotations
          when it could just the StandardMBean semantic.
          If you weren't allowing access through an interface, the annotations would
          make more sense (the usual detyped jmx access through the console).

          4) If all you want to do is avoid the XXXMBean rule,
          javax.management.StandardMBean allows you to override the interface exposed.
          The only requirement is that the object implements the interface.

          • 2. Re: Generate MBeanInfo from arbitrary interface
            Adrian Brock Master

            I should also note, that it is on the roadmap to be able to define
            an MBean using annotations for the JMX2.0 spec.

            • 3. Re: Generate MBeanInfo from arbitrary interface
              Kabir Khan Master

              1) and 2) It is for a singleton instance, i.e. the @Service bean type

              3) The management interface is implemented by the singleton, it just does not need to follow the standard mbean naming convention. So instead of

              public class SomeClass implements SomeClassMBean

              we have
              public class SomeClass implements AnInterface
              public interface AnInterface

              4) Thanks, I'll give that a go