public final ObjectName registerMBean ( Object pMBean , String ... pOptionalName ) throws MalformedObjectNameException , NotCompliantMBeanException , InstanceAlreadyExistsException { synchronized ( mBeanHandles ) { MBeanServer server = ManagementFactory . getPlatformMBeanServer ( ) ; try { String name = pOptionalName != null && pOptionalName . length > 0 ? pOptionalName [ 0 ] : null ; ObjectName registeredName = serverHandle . registerMBeanAtServer ( server , pMBean , name ) ; mBeanHandles . add ( new MBeanHandle ( server , registeredName ) ) ; return registeredName ; } catch ( RuntimeException exp ) { throw new IllegalStateException ( "Could not register " + pMBean + ": " + exp , exp ) ; } catch ( MBeanRegistrationException exp ) { throw new IllegalStateException ( "Could not register " + pMBean + ": " + exp , exp ) ; } } }
Register a MBean under a certain name to the platform MBeanServer