Class JMXRegistrationManager


  • public class JMXRegistrationManager
    extends java.lang.Object
    A simple class that implements deferred registration. When registration is suspended, mbean registrations are queued until registration is resumed, at which time the registration are processed in order.
    • Field Detail

      • suspendCount

        private int suspendCount
      • rootParentName

        private final javax.management.ObjectName rootParentName
      • lock

        final java.lang.Object lock
      • deferredRegistrations

        private final java.util.LinkedHashSet<MBeanImpl> deferredRegistrations
      • isJMXRegistrationEnabled

        boolean isJMXRegistrationEnabled
      • rpListener

        private org.glassfish.external.amx.MBeanListener rpListener
    • Constructor Detail

    • Method Detail

      • setRoot

        public void setRoot​(MBeanImpl root)
                     throws javax.management.InstanceAlreadyExistsException,
                            javax.management.MBeanRegistrationException,
                            javax.management.NotCompliantMBeanException
        Set the MBeanImpl that is the root of this MBean tree. Must be set before other methods are called (but this is not enforced).
        Parameters:
        root - The root of the tree.
        Throws:
        javax.management.InstanceAlreadyExistsException
        javax.management.MBeanRegistrationException
        javax.management.NotCompliantMBeanException
      • clear

        void clear()
      • suspendRegistration

        public void suspendRegistration()
        Increment the suspended registration count. All registrations with JMX are suspended while suspendCount > 0.
      • resumeRegistration

        public void resumeRegistration()
        Decrement the suspended registration count. If the count goes to zero. all registrations that occurred while suspendCount > 0 are registered with the JMX server, UNLESS isJMXRegistrationEnabled is false, in which case we simply clear the deferredRegistrations list, because all MBean will be registered once the root is available.
      • register

        public void register​(MBeanImpl mb)
                      throws javax.management.InstanceAlreadyExistsException,
                             javax.management.MBeanRegistrationException,
                             javax.management.NotCompliantMBeanException
        Handle registration of this MBean. If we are suspended, simply add to the deferredRegistrationList and mark the MBean as suspended. If we are not suspended, then register if JMX registration is enabled.
        Parameters:
        mb - The MBeanImpl to register
        Throws:
        javax.management.InstanceAlreadyExistsException
        javax.management.MBeanRegistrationException
        javax.management.NotCompliantMBeanException
      • unregister

        public void unregister​(MBeanImpl mb)
                        throws javax.management.InstanceNotFoundException,
                               javax.management.MBeanRegistrationException
        Unregister the MBean. If we are suspended, remove from the deferredRegistrations list and mark suspended false. In any case, we unregister from JMX if JMX registration is enabled. Note that we may call unregister on an unregistered object if suspendCount > 0, but that's OK, because MBean.unregister does nothing if mb is not registered.
        Parameters:
        mb - The MBean to unregister.
        Throws:
        javax.management.InstanceNotFoundException
        javax.management.MBeanRegistrationException