public final void destroy ( ) throws JMException { synchronized ( mBeanHandles ) { List < JMException > exceptions = new ArrayList < JMException > ( ) ; List < MBeanHandle > unregistered = new ArrayList < MBeanHandle > ( ) ; for ( MBeanHandle handle : mBeanHandles ) { try { unregistered . add ( handle ) ; handle . server . unregisterMBean ( handle . objectName ) ; } catch ( InstanceNotFoundException e ) { exceptions . add ( e ) ; } catch ( MBeanRegistrationException e ) { exceptions . add ( e ) ; } } // Remove all successfully unregistered handles mBeanHandles . removeAll ( unregistered ) ; // Throw error if any exception occured during unregistration if ( exceptions . size ( ) == 1 ) { throw exceptions . get ( 0 ) ; } else if ( exceptions . size ( ) > 1 ) { StringBuilder ret = new StringBuilder ( ) ; for ( JMException e : exceptions ) { ret . append ( e . getMessage ( ) ) . append ( ", " ) ; } throw new JMException ( ret . substring ( 0 , ret . length ( ) - 2 ) ) ; } } // Unregister any notification listener mBeanServerManager . destroy ( ) ; }
Unregister all previously registered MBean . This is tried for all previously registered MBeans