public static void register ( String name , Object instance ) { try { Class < Object > mbeanInterface = guessMBeanInterface ( instance ) ; ManagementFactory . getPlatformMBeanServer ( ) . registerMBean ( new StandardMBean ( instance , mbeanInterface ) , new ObjectName ( name ) ) ; } catch ( MalformedObjectNameException | NotCompliantMBeanException | InstanceAlreadyExistsException | MBeanRegistrationException e ) { throw new IllegalStateException ( "Can not register MBean [" + name + "]" , e ) ; } }
Register a MBean to JMX server