public static void tryRegister(@Nonnull final Object mbean, @Nonnull final ObjectName objectName)
    {
        if (!isEnabled()) {
            Log.trace("Not Registering MBean with platform MBean server (using object name: {}) as JMX functionality in Openfire is disabled.", objectName);
            return;
        }

        getInstance(); // Ensure that the instance is started before trying to register anything.

        Log.trace("Registering MBean with platform MBean server, using object name: {}", objectName);
        tryUnregister(objectName);

        try {
            getInstance().getContainer().getMBeanServer().registerMBean(mbean, objectName);
            Log.debug("Successfully registered MBean with platform MBean server, using object name: {}", objectName);
        } catch (Exception e) {
            Log.warn("Failed to register MBean with platform MBean server, using object name: {}", objectName, e);
        }
    }
Registers a MBean in the platform MBean server, replacing any MBean that might have been registered earlier using
the same object name.

This method will log but otherwise ignore any exception that is thrown when registrating the bean.

@param mbean The bean to register
@param objectName The identifier to register the bean under.
xmppserver/src/main/java/org/jivesoftware/openfire/JMXManager.java