Class JmxUtil


  • public class JmxUtil
    extends java.lang.Object
    Utility class for JMX registration of JDBC pool components.

    JMX is a best-effort management channel, not part of the pool's operation. A registration or an unregistration is attempted once and a failure is logged; nothing is retried later from this class.

    Under Catalina the names are unique - the container assigns them, and a name identifies one live component - so a refused registration is a configuration or server problem that an operator reads from the log, not one the pool should keep hammering. Retrying a refused unregistration by name would be worse than leaving it: by the time the retry ran, the name could belong to a replacement MBean, and the retry would silently take down the replacement's management surface.

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static javax.management.ObjectName registerJmx​(javax.management.ObjectName base, java.lang.String keyprop, java.lang.Object obj)
      Register an object as an MBean.
      static boolean unregisterJmx​(javax.management.ObjectName oname)
      Unregister an MBean.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • registerJmx

        public static javax.management.ObjectName registerJmx​(javax.management.ObjectName base,
                                                              java.lang.String keyprop,
                                                              java.lang.Object obj)
        Register an object as an MBean.
        Parameters:
        base - the base object name, or null to register nothing - the skip a component whose own registration is absent relies on, so it is deliberate and unlogged
        keyprop - the key property
        obj - the object to register
        Returns:
        the registered object name, or null on failure - or on the absent-base skip. A registration the MBean server refused - because the name is already in use by another MBean, for instance - is such a failure, so a non-null name always means this call is the one that published the object under that name
      • unregisterJmx

        public static boolean unregisterJmx​(javax.management.ObjectName oname)
        Unregister an MBean.
        Parameters:
        oname - the object name to unregister, or null to release nothing
        Returns:
        true if the name is no longer registered - either this call took it down, or it was already gone, or there was nothing to release; false if the MBean server refused to unregister it, which means the MBean is normally still published under that name and, since callers drop their handle regardless, held by nothing for the rest of the JVM's life (an MBean whose postDeregister() throws reports the same failure although the server already took it down; the pool's own MBeans never do). A refusal is reported here and not remembered for a later retry: see the class documentation.