code: 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");
      }
docs: Register the JMX agent
  
  @throws java.lang.Exception