private MBeanServer getServerForName ( String name ) { try { MBeanServer mbeanServer = null ; final ObjectName objectNameQuery = new ObjectName ( name + ":type=Service,*" ) ; for ( final MBeanServer server : MBeanServerFactory . findMBeanServer ( null ) ) { if ( server . queryNames ( objectNameQuery , null ) . size ( ) > 0 ) { mbeanServer = server ; // we found it, bail out break ; } } return mbeanServer ; } catch ( Exception e ) { } return null ; }
Returns an MBeanServer with the specified name