Registers an MBean per the given MBean definition in an MBeanServer of implementation choice. Registration process involves loading of MBean Class by a class-loader of implementation choice, instantiating it, registering it in the MBeanServer and initializing it if the configuration (MBeanDefinition) has it. If the initialization of the MBean fails, a RuntimeException is thrown and the MBean is deregistered if it was registered. Appropriate exceptions are available in the stack of the exceptions at every stage during registration, as follows:
- ClassNotFoundException, NoClassDefFoundError if the class could not be loaded
- ExceptionInInitializerError, IllegalAccessException, InstantiationException if the MBean instance could not be created
- Standard attribute setting exceptions from MBeanServer's setAttribute(Attribute, Object) contract
The initialization is done using several calls to setAttribute(Attribute, Object) on the MBeanServer so as to know setting what attribute causes a problem, if any.
@return ObjectName with which the MBean is going to be actually registered. If the Mbean definition given is not enabled,a null is returned