/** * Unregisters all runtime MBeans that are registered in the same domain as the * MessageBrokerControl for the target MessageBroker. * * @param broker The MessageBroker component that has been stopped. */ public static void unregisterRuntimeMBeans(MessageBroker broker) { MBeanServer server = MBeanServerLocatorFactory.getMBeanServerLocator().getMBeanServer(); ObjectName brokerMBean = broker.getControl().getObjectName(); String domain = brokerMBean.getDomain(); try { ObjectName pattern = new ObjectName(domain + ":*"); Set names = server.queryNames(pattern, null); Iterator iter = names.iterator(); while (iter.hasNext()) { ObjectName on = (ObjectName) iter.next(); server.unregisterMBean(on); } } catch (Exception e) { // We're generally unregistering these during shutdown (possibly JVM shutdown) // so there's nothing to really do here because we aren't guaranteed access to // resources like system log files, localized messaging, etc. } }
/** * This method is invoked to allow the <code>MessageService</code> to instantiate and register its * MBean control. * * @param broker The <code>MessageBroker</code> to pass to the <code>MessageServiceControl</code> * constructor. */ @Override protected void setupServiceControl(MessageBroker broker) { controller = new MessageServiceControl(this, broker.getControl()); controller.register(); setControl(controller); }