Class AbstractJmxBridge<MXBean>

java.lang.Object
com.atlassian.plugin.jmx.AbstractJmxBridge<MXBean>

public abstract class AbstractJmxBridge<MXBean> extends Object
An base class for managing registration and unregistration of a JMX MXBean.

This implementation keeps a weak reference to the underlying implementation so that failing to unregister from the platform MBean server does not leak implementation instances. In the event of usage after the implementation is garbage collected, an IllegalStateException is thrown.

The idiomatic usage of this class is to subclass, pass the MXBean interface type as parameter, directly implement the MXBean using a strong reference to the required system components, and override getMXBean() to return this. The register() method will construct a proxy which weakly references this implementation.

Since:
v3.0.24
  • Constructor Details

    • AbstractJmxBridge

      public AbstractJmxBridge(ObjectName objectName, Class<MXBean> mxBeanClass)
      Construct given JMX ObjectName and interface class.
      Parameters:
      objectName - the ObjectName to register under.
      mxBeanClass - the interface class for the MXBean.
  • Method Details

    • getMXBean

      protected abstract MXBean getMXBean()
      Obtain the actual MXBean implementation.

      The return value is weakly held.

      Returns:
      The implementation of the MXBean to expose via JMX.
    • register

      public void register()
      Register the MXBean with the platform MBean server.
    • getObjectName

      public ObjectName getObjectName()
    • unregister

      public void unregister()
      Unregister the MXBean from the platform MBean server.