code: void handleMBeans(final HikariPool hikariPool, final boolean register)
     {
        if (!config.isRegisterMbeans()) {
           return;
        }
  
        try {
           final MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
  
           final ObjectName beanConfigName = new ObjectName("com.zaxxer.hikari:type=PoolConfig (" + poolName + ")");
           final ObjectName beanPoolName = new ObjectName("com.zaxxer.hikari:type=Pool (" + poolName + ")");
           if (register) {
              if (!mBeanServer.isRegistered(beanConfigName)) {
                 mBeanServer.registerMBean(config, beanConfigName);
                 mBeanServer.registerMBean(hikariPool, beanPoolName);
              } else {
                 logger.error("{} - JMX name ({}) is already registered.", poolName, poolName);
              }
           }
           else if (mBeanServer.isRegistered(beanConfigName)) {
              mBeanServer.unregisterMBean(beanConfigName);
              mBeanServer.unregisterMBean(beanPoolName);
           }
        }
        catch (Exception e) {
           logger.warn("{} - Failed to {} management beans.", poolName, (register ? "register" : "unregister"), e);
        }
     }
docs: Register MBeans for HikariConfig and HikariPool.
  
  @param hikariPool a HikariPool instance