public static void unregisterMBean(Class<?> mbeanInterface,String mbeanName){
  MBeanServer mbs=ManagementFactory.getPlatformMBeanServer();
  try {
    ObjectName name=generateMBeanObjectName(mbeanInterface.getName(),mbeanName);
    if (mbs.isRegistered(name)) {
      logger.info("Unregistering mbean: " + name.toString());
      mbs.unregisterMBean(name);
    }
 else {
      logger.warn("Ignoring attempt to unregister unknown mbean: " + name.toString());
    }
  }
 catch (  Exception e) {
    throw new ServerRuntimeException("Unable to unregister mbean: interface=" + mbeanInterface + " name="+ mbeanName,e);
  }
}

public static void unregisterMBean ( Class < ? > mbeanInterface , String mbeanName ) { MBeanServer mbs = ManagementFactory . getPlatformMBeanServer ( ) ; try { ObjectName name = generateMBeanObjectName ( mbeanInterface . getName ( ) , mbeanName ) ; if ( mbs . isRegistered ( name ) ) { logger . info ( "Unregistering mbean: " + name . toString ( ) ) ; mbs . unregisterMBean ( name ) ; } else { logger . warn ( "Ignoring attempt to unregister unknown mbean: " + name . toString ( ) ) ; } } catch ( Exception e ) { throw new ServerRuntimeException ( "Unable to unregister mbean: interface=" + mbeanInterface + " name=" + mbeanName , e ) ; } }
server helper method to register a jmx mbean . mbeans are registered by a combination of their mbean interface and the custom mbeanname argument . the mbeanname permits multiple mbeans to be registered under the same name .
