code: @SuppressWarnings("unchecked")
    public static void registerMBean(final ManagementContext context,
                                     final Object object,
                                     final ObjectName objectName)
      throws Exception {
  
      String mbeanName = object.getClass().getName() + "MBean";
  
      for (Class c : object.getClass().getInterfaces()) {
        if (mbeanName.equals(c.getName())) {
          context.registerMBean(new AnnotatedMBean(object, c), objectName);
          return;
        }
      }
  
      context.registerMBean(object, objectName);
    }
docs: Register an mbean with the jmx context
  
  @param context
  @param object
  @param objectName
  @throws Exception