Java MBean registerMBean(Object bean, MBeanServer mBeanServer, ObjectName objectName)

Here you can find the source of registerMBean(Object bean, MBeanServer mBeanServer, ObjectName objectName)

Description

register M Bean

License

Apache License

Declaration

static void registerMBean(Object bean, MBeanServer mBeanServer, ObjectName objectName) throws Exception 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import javax.management.MBeanServer;
import javax.management.ObjectName;

public class Main {
    static void registerMBean(Object bean, MBeanServer mBeanServer, ObjectName objectName) throws Exception {
        if (!mBeanServer.isRegistered(objectName)) {
            mBeanServer.registerMBean(bean, objectName);
        } else {//  w w w .j a va2 s .c  o  m
            unregisterMBean(mBeanServer, objectName);
            mBeanServer.registerMBean(bean, objectName);
        }
    }

    static void unregisterMBean(MBeanServer mBeanServer, ObjectName objectName) throws Exception {
        if (mBeanServer.isRegistered(objectName)) {
            mBeanServer.unregisterMBean(objectName);
        }
    }
}

Related

  1. queryAndGetAttribute(MBeanServerConnection connection, String domain, String name, String type, String scope, String attribute)
  2. queryConnectionBy(MBeanServerConnection connection, ObjectName objectName)
  3. readAttribute(MBeanServer mbeanServer, String mbeanName, String attributeName)
  4. registerMBean(MBeanServer mbs, Object object, ObjectName name, boolean unreg)
  5. registerMBean(MBeanServer server, String agentName, Map attrs, Object mbeanObject)
  6. removeTimerNotification(ObjectName timer, Integer id, MBeanServer server)
  7. resolveServerClassLoader(Map env, MBeanServer mbs)
  8. setQueryExpServer(QueryExp query, MBeanServer toSet)
  9. toString(MBeanParameterInfo[] pinfo)