1 Reply Latest reply on Apr 22, 2003 8:38 AM by Eric Jain

    How to instantiate XMBean

    Eric Jain Newbie

      How do you instantiate an XMBean programmatically? None of the createMBean methods in the MBeanServer interface allow the location of the XMBean's XML descriptor to be set.

        • 1. Re: How to instantiate XMBean
          Eric Jain Newbie

          Never mind...

          [pre]List servers = MBeanServerFactory.findMBeanServer(null);
          MBeanServer server = (MBeanServer) servers.get(0);

          Descriptor d = new DescriptorSupport();
          d.setField(RESOURCE_REFERENCE, new TextIndexUpdater());
          d.setField(RESOURCE_TYPE, "resource:META-INF/TextIndexUpdater.xml");
          d.setField(SAX_PARSER, "org.apache.crimson.parser.XMLReaderImpl");

          XMBean mbean = new XMBean(d, DESCRIPTOR);
          ObjectName name = new ObjectName("test.org:service=TextIndex,type=Updater,source=" + source);
          server.registerMBean(mbean, name);
          server.setAttribute(name, new Attribute("Source", source));