6 Replies Latest reply on Mar 19, 2003 3:03 PM by adrian.brock

    Dynamic Registration of MBean

    cbono

      We have an application that has to run on multiple appservers (jboss and weblogic namely). In our application we have about 10 services (MBeans). Currently for each of these services we have an entry in the appserver specific config file that defines the service.

      We want to create a generic service loader that loads all of these services in a generic fashion (same across weblogic, jboss, etc..). The reason is that otherwise we would have to keep track of multiple proprietary config files w/ 10 proprietary specific configurations in each file. Basically with this approach we will have one MBean (GenericServiceLoader) that has to be bootstrapped to the appserver (thus only 1 entry in the config file to deal with). Now in order to achieve this we have to abstract out the "installation" of the service into the JMX implementation. So finally, my question is what is the recommended method for registering mbeans at runtime into the jboss jmx impl?

      Thanks

        • 1. Re: Dynamic Registration of MBean

          A sar or your-service.xml

          Regards,
          Adrian

          • 2. Re: Dynamic Registration of MBean
            cbono

            Adrian,

            I think my post was a bit misleading. What I am trying to do is programatically register an MBean, not declaratively. I know that I can get ahold of the MBeanServer and call createMBean(clazz,oName) but I am not sure if that call will result in all of the JBoss impl hooks/plumbing to be initialized properly.

            • 3. Re: Dynamic Registration of MBean
              cbono

              I think my post was a bit misleading. I am trying to programatically register an MBean through another MBean. I know that I can do it via MBeanServer.createMBean(clazz,oName) but I am not sure if that will properly call into the impl hooks and initialize it properly.

              Thanks.

              • 4. Re: Dynamic Registration of MBean

                Yes, MBeanServer.createMBean() for your own deployer MBean will work.

                • 5. Re: Dynamic Registration of MBean
                  cbono

                  Thanks Juha,

                  So what is the best way to get a ref to the MBeanServer impl in JBoss. I believe I can use javax.management.MBeanServerFactory.findMBeanServer(agentID:String). If so, what is the "agentID" that I should use? Is this the most straight forward approach? I like this approach as my code will have 0 proprietary calls in it.

                  Thanks.

                  • 6. Re: Dynamic Registration of MBean

                    There is only one MBeanServer in jboss,
                    simply use the following to get the "first".

                    findMBeanServer(null).iterator().next();

                    Regards,
                    Adrian