public synchronized void register ( ) throws Exception { if ( mbeanName != null ) { throw new Exception ( "Agent already registered" ) ; } mbeanName = new ObjectName ( getClass ( ) . getPackage ( ) . getName ( ) + ":type=" + getClass ( ) . getSimpleName ( ) ) ; logger . info ( "Registering JMX agent " + mbeanName ) ; ManagementFactory . getPlatformMBeanServer ( ) . registerMBean ( this , mbeanName ) ; logger . info ( "JMX agent " + mbeanName + " registered" ) ; }
Register the JMX agent