2 Replies Latest reply on Jun 27, 2003 5:10 AM by Marius Krabset

    Getting MBeanServer from inside jvm

    Marius Krabset Newbie

      Hi, I want to dynamically instanciate new mbeans from a sar-deployed "service-mbean". What is the best way for the service-mbean to get a reference to its mbeanserver...

      I could do like this:
      private MBeanServer getMBeanServer() {
      List srvrList = MBeanServerFactory.findMBeanServer(null);
      return (MBeanServer)srvrList.iterator().next();
      }

      , but do I have a guarantee for that the find-method returns a list with only one element. What if I for some strange reason should have more than one mbean-server?

      I could also search through the list for an mbean-server which recognizes the ObjectName of the already registered service-mbean (which I call from), but is there an easier/better/safer way ?