code: private static void register(ObjectName objectName, Object mbean) {
      MBeanServer server = ManagementFactory.getPlatformMBeanServer();
      try {
        if (!server.isRegistered(objectName)) {
          server.registerMBean(mbean, objectName);
        }
      } catch (InstanceAlreadyExistsException
          | MBeanRegistrationException | NotCompliantMBeanException e) {
        throw new CacheException("Error registering " + objectName, e);
      }
    }
docs: Registers the management bean with the given object name.