public static int unregisterMBeans ( String filter , MBeanServer mBeanServer ) { try { ObjectName filterObjName = new ObjectName ( filter ) ; Set < ObjectInstance > mbeans = mBeanServer . queryMBeans ( filterObjName , null ) ; for ( ObjectInstance mbean : mbeans ) { ObjectName name = mbean . getObjectName ( ) ; if ( trace ) log . trace ( "Unregistering mbean with name: " + name ) ; SecurityActions . unregisterMBean ( name , mBeanServer ) ; } return mbeans . size ( ) ; } catch ( Exception e ) { throw new CacheException ( "Unable to register mbeans with filter=" + filter , e ) ; } }
Unregister all mbeans whose object names match a given filter .