Class SingleMBeanObject<I>

  • Type Parameters:
    I - The Type of Object to expose as an MBean. Currently only used with SingleMBeanObject

    public class SingleMBeanObject<I>
    extends Object
    Wrapper class for registering objects of type I as MBeans.

    The register method will register a given object under an object name, generated with the domain given in constructor, and fields from the Hashtable nameProperties. It is prefilled with values common for all MBeans, but it is expected to be extended after the object is created with additional info.

    • Constructor Detail

      • SingleMBeanObject

        public SingleMBeanObject​(String domain,
                                 I object,
                                 Class<I> asInterface,
                                 MBeanServer mBeanServer)
        Create a single mbean object. This will fill out nameProperties with default values, and remember the domain and interface given. It will not, however, register the MBean.
        Parameters:
        domain - The domain of the MBean.
        object - The object to expose as an MBean.
        asInterface - The interface this MBean is exposed as.
        mBeanServer - The server to register the mbean in.
        Throws:
        ArgumentNotValid - If domain is null or empty, or any other argument is null.
      • SingleMBeanObject

        public SingleMBeanObject​(ObjectName name,
                                 I o,
                                 Class<I> asInterface,
                                 MBeanServer mBeanServer)
        Create a single mbean object.

        This is a helper method for the constructor taking a domain, which take the domain from a preconstructed ObjectName and replaces the nameProperties with the properties from the given object name. Use this if you have an object name created already, which you wish to use.

        Parameters:
        name - The object name to register under.
        o - The object to register.
        asInterface - The interface o should implement.
        mBeanServer - The mbean server to register o in.
        Throws:
        ArgumentNotValid - on any null parameter.
    • Method Detail

      • getNameProperties

        public Hashtable<String,​String> getNameProperties()
        Properties for the ObjectName name. Update these before registering. On construction, initialised with location, hostname, httpport, priority, replica, applicationname, applicationinstid.
        Returns:
        Hashtable of the object name properties.
      • register

        public void register()
        Registers this object as a standard MBean, with a name generated from domain given in constructor and the nameProperties hashTable.
        Throws:
        IllegalState - if bean is already registered.
        IOFailure - on trouble registering.
      • unregister

        public void unregister()
                        throws IOFailure
        Unregister the object from the MBeanServer. Note: It is not checked that it is actually this mbean that is registered under the name, this method simply unregisters any object with this object name.
        Throws:
        IOFailure - on trouble unregistering.
      • getName

        public ObjectName getName()
        Returns:
        the name