Java Code Examples for com.sun.jmx.mbeanserver.Introspector#makeDynamicMBean()

The following examples show how to use com.sun.jmx.mbeanserver.Introspector#makeDynamicMBean() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultMBeanServerInterceptor.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
/**
 * Register <code>object</code> in the repository, with the
 * given <code>name</code>.
 * This method is called by the various createMBean() flavours
 * and by registerMBean() after all MBean compliance tests
 * have been performed.
 * <p>
 * This method does not performed any kind of test compliance,
 * and the caller should make sure that the given <code>object</code>
 * is MBean compliant.
 * <p>
 * This methods performed all the basic steps needed for object
 * registration:
 * <ul>
 * <li>If the <code>object</code> implements the MBeanRegistration
 *     interface, it invokes preRegister() on the object.</li>
 * <li>Then the object is added to the repository with the given
 *     <code>name</code>.</li>
 * <li>Finally, if the <code>object</code> implements the
 *     MBeanRegistration interface, it invokes postRegister()
 *     on the object.</li>
 * </ul>
 * @param object A reference to a MBean compliant object.
 * @param name   The ObjectName of the <code>object</code> MBean.
 * @return the actual ObjectName with which the object was registered.
 * @exception InstanceAlreadyExistsException if an object is already
 *            registered with that name.
 * @exception MBeanRegistrationException if an exception occurs during
 *            registration.
 **/
private ObjectInstance registerObject(String classname,
                                      Object object, ObjectName name)
    throws InstanceAlreadyExistsException,
           MBeanRegistrationException,
           NotCompliantMBeanException {

    if (object == null) {
        final RuntimeException wrapped =
            new IllegalArgumentException("Cannot add null object");
        throw new RuntimeOperationsException(wrapped,
                    "Exception occurred trying to register the MBean");
    }

    DynamicMBean mbean = Introspector.makeDynamicMBean(object);

    return registerDynamicMBean(classname, mbean, name);
}
 
Example 2
Source File: DefaultMBeanServerInterceptor.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Register <code>object</code> in the repository, with the
 * given <code>name</code>.
 * This method is called by the various createMBean() flavours
 * and by registerMBean() after all MBean compliance tests
 * have been performed.
 * <p>
 * This method does not performed any kind of test compliance,
 * and the caller should make sure that the given <code>object</code>
 * is MBean compliant.
 * <p>
 * This methods performed all the basic steps needed for object
 * registration:
 * <ul>
 * <li>If the <code>object</code> implements the MBeanRegistration
 *     interface, it invokes preRegister() on the object.</li>
 * <li>Then the object is added to the repository with the given
 *     <code>name</code>.</li>
 * <li>Finally, if the <code>object</code> implements the
 *     MBeanRegistration interface, it invokes postRegister()
 *     on the object.</li>
 * </ul>
 * @param object A reference to a MBean compliant object.
 * @param name   The ObjectName of the <code>object</code> MBean.
 * @return the actual ObjectName with which the object was registered.
 * @exception InstanceAlreadyExistsException if an object is already
 *            registered with that name.
 * @exception MBeanRegistrationException if an exception occurs during
 *            registration.
 **/
private ObjectInstance registerObject(String classname,
                                      Object object, ObjectName name)
    throws InstanceAlreadyExistsException,
           MBeanRegistrationException,
           NotCompliantMBeanException {

    if (object == null) {
        final RuntimeException wrapped =
            new IllegalArgumentException("Cannot add null object");
        throw new RuntimeOperationsException(wrapped,
                    "Exception occurred trying to register the MBean");
    }

    DynamicMBean mbean = Introspector.makeDynamicMBean(object);

    return registerDynamicMBean(classname, mbean, name);
}
 
Example 3
Source File: DefaultMBeanServerInterceptor.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Register <code>object</code> in the repository, with the
 * given <code>name</code>.
 * This method is called by the various createMBean() flavours
 * and by registerMBean() after all MBean compliance tests
 * have been performed.
 * <p>
 * This method does not performed any kind of test compliance,
 * and the caller should make sure that the given <code>object</code>
 * is MBean compliant.
 * <p>
 * This methods performed all the basic steps needed for object
 * registration:
 * <ul>
 * <li>If the <code>object</code> implements the MBeanRegistration
 *     interface, it invokes preRegister() on the object.</li>
 * <li>Then the object is added to the repository with the given
 *     <code>name</code>.</li>
 * <li>Finally, if the <code>object</code> implements the
 *     MBeanRegistration interface, it invokes postRegister()
 *     on the object.</li>
 * </ul>
 * @param object A reference to a MBean compliant object.
 * @param name   The ObjectName of the <code>object</code> MBean.
 * @return the actual ObjectName with which the object was registered.
 * @exception InstanceAlreadyExistsException if an object is already
 *            registered with that name.
 * @exception MBeanRegistrationException if an exception occurs during
 *            registration.
 **/
private ObjectInstance registerObject(String classname,
                                      Object object, ObjectName name)
    throws InstanceAlreadyExistsException,
           MBeanRegistrationException,
           NotCompliantMBeanException {

    if (object == null) {
        final RuntimeException wrapped =
            new IllegalArgumentException("Cannot add null object");
        throw new RuntimeOperationsException(wrapped,
                    "Exception occurred trying to register the MBean");
    }

    DynamicMBean mbean = Introspector.makeDynamicMBean(object);

    return registerDynamicMBean(classname, mbean, name);
}
 
Example 4
Source File: DefaultMBeanServerInterceptor.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Register <code>object</code> in the repository, with the
 * given <code>name</code>.
 * This method is called by the various createMBean() flavours
 * and by registerMBean() after all MBean compliance tests
 * have been performed.
 * <p>
 * This method does not performed any kind of test compliance,
 * and the caller should make sure that the given <code>object</code>
 * is MBean compliant.
 * <p>
 * This methods performed all the basic steps needed for object
 * registration:
 * <ul>
 * <li>If the <code>object</code> implements the MBeanRegistration
 *     interface, it invokes preRegister() on the object.</li>
 * <li>Then the object is added to the repository with the given
 *     <code>name</code>.</li>
 * <li>Finally, if the <code>object</code> implements the
 *     MBeanRegistration interface, it invokes postRegister()
 *     on the object.</li>
 * </ul>
 * @param object A reference to a MBean compliant object.
 * @param name   The ObjectName of the <code>object</code> MBean.
 * @return the actual ObjectName with which the object was registered.
 * @exception InstanceAlreadyExistsException if an object is already
 *            registered with that name.
 * @exception MBeanRegistrationException if an exception occurs during
 *            registration.
 **/
private ObjectInstance registerObject(String classname,
                                      Object object, ObjectName name)
    throws InstanceAlreadyExistsException,
           MBeanRegistrationException,
           NotCompliantMBeanException {

    if (object == null) {
        final RuntimeException wrapped =
            new IllegalArgumentException("Cannot add null object");
        throw new RuntimeOperationsException(wrapped,
                    "Exception occurred trying to register the MBean");
    }

    DynamicMBean mbean = Introspector.makeDynamicMBean(object);

    return registerDynamicMBean(classname, mbean, name);
}
 
Example 5
Source File: DefaultMBeanServerInterceptor.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
/**
 * Register <code>object</code> in the repository, with the
 * given <code>name</code>.
 * This method is called by the various createMBean() flavours
 * and by registerMBean() after all MBean compliance tests
 * have been performed.
 * <p>
 * This method does not performed any kind of test compliance,
 * and the caller should make sure that the given <code>object</code>
 * is MBean compliant.
 * <p>
 * This methods performed all the basic steps needed for object
 * registration:
 * <ul>
 * <li>If the <code>object</code> implements the MBeanRegistration
 *     interface, it invokes preRegister() on the object.</li>
 * <li>Then the object is added to the repository with the given
 *     <code>name</code>.</li>
 * <li>Finally, if the <code>object</code> implements the
 *     MBeanRegistration interface, it invokes postRegister()
 *     on the object.</li>
 * </ul>
 * @param object A reference to a MBean compliant object.
 * @param name   The ObjectName of the <code>object</code> MBean.
 * @return the actual ObjectName with which the object was registered.
 * @exception InstanceAlreadyExistsException if an object is already
 *            registered with that name.
 * @exception MBeanRegistrationException if an exception occurs during
 *            registration.
 **/
private ObjectInstance registerObject(String classname,
                                      Object object, ObjectName name)
    throws InstanceAlreadyExistsException,
           MBeanRegistrationException,
           NotCompliantMBeanException {

    if (object == null) {
        final RuntimeException wrapped =
            new IllegalArgumentException("Cannot add null object");
        throw new RuntimeOperationsException(wrapped,
                    "Exception occurred trying to register the MBean");
    }

    DynamicMBean mbean = Introspector.makeDynamicMBean(object);

    return registerDynamicMBean(classname, mbean, name);
}
 
Example 6
Source File: DefaultMBeanServerInterceptor.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Register <code>object</code> in the repository, with the
 * given <code>name</code>.
 * This method is called by the various createMBean() flavours
 * and by registerMBean() after all MBean compliance tests
 * have been performed.
 * <p>
 * This method does not performed any kind of test compliance,
 * and the caller should make sure that the given <code>object</code>
 * is MBean compliant.
 * <p>
 * This methods performed all the basic steps needed for object
 * registration:
 * <ul>
 * <li>If the <code>object</code> implements the MBeanRegistration
 *     interface, it invokes preRegister() on the object.</li>
 * <li>Then the object is added to the repository with the given
 *     <code>name</code>.</li>
 * <li>Finally, if the <code>object</code> implements the
 *     MBeanRegistration interface, it invokes postRegister()
 *     on the object.</li>
 * </ul>
 * @param object A reference to a MBean compliant object.
 * @param name   The ObjectName of the <code>object</code> MBean.
 * @return the actual ObjectName with which the object was registered.
 * @exception InstanceAlreadyExistsException if an object is already
 *            registered with that name.
 * @exception MBeanRegistrationException if an exception occurs during
 *            registration.
 **/
private ObjectInstance registerObject(String classname,
                                      Object object, ObjectName name)
    throws InstanceAlreadyExistsException,
           MBeanRegistrationException,
           NotCompliantMBeanException {

    if (object == null) {
        final RuntimeException wrapped =
            new IllegalArgumentException("Cannot add null object");
        throw new RuntimeOperationsException(wrapped,
                    "Exception occurred trying to register the MBean");
    }

    DynamicMBean mbean = Introspector.makeDynamicMBean(object);

    return registerDynamicMBean(classname, mbean, name);
}
 
Example 7
Source File: DefaultMBeanServerInterceptor.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Register <code>object</code> in the repository, with the
 * given <code>name</code>.
 * This method is called by the various createMBean() flavours
 * and by registerMBean() after all MBean compliance tests
 * have been performed.
 * <p>
 * This method does not performed any kind of test compliance,
 * and the caller should make sure that the given <code>object</code>
 * is MBean compliant.
 * <p>
 * This methods performed all the basic steps needed for object
 * registration:
 * <ul>
 * <li>If the <code>object</code> implements the MBeanRegistration
 *     interface, it invokes preRegister() on the object.</li>
 * <li>Then the object is added to the repository with the given
 *     <code>name</code>.</li>
 * <li>Finally, if the <code>object</code> implements the
 *     MBeanRegistration interface, it invokes postRegister()
 *     on the object.</li>
 * </ul>
 * @param object A reference to a MBean compliant object.
 * @param name   The ObjectName of the <code>object</code> MBean.
 * @return the actual ObjectName with which the object was registered.
 * @exception InstanceAlreadyExistsException if an object is already
 *            registered with that name.
 * @exception MBeanRegistrationException if an exception occurs during
 *            registration.
 **/
private ObjectInstance registerObject(String classname,
                                      Object object, ObjectName name)
    throws InstanceAlreadyExistsException,
           MBeanRegistrationException,
           NotCompliantMBeanException {

    if (object == null) {
        final RuntimeException wrapped =
            new IllegalArgumentException("Cannot add null object");
        throw new RuntimeOperationsException(wrapped,
                    "Exception occurred trying to register the MBean");
    }

    DynamicMBean mbean = Introspector.makeDynamicMBean(object);

    return registerDynamicMBean(classname, mbean, name);
}
 
Example 8
Source File: DefaultMBeanServerInterceptor.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Register <code>object</code> in the repository, with the
 * given <code>name</code>.
 * This method is called by the various createMBean() flavours
 * and by registerMBean() after all MBean compliance tests
 * have been performed.
 * <p>
 * This method does not performed any kind of test compliance,
 * and the caller should make sure that the given <code>object</code>
 * is MBean compliant.
 * <p>
 * This methods performed all the basic steps needed for object
 * registration:
 * <ul>
 * <li>If the <code>object</code> implements the MBeanRegistration
 *     interface, it invokes preRegister() on the object.</li>
 * <li>Then the object is added to the repository with the given
 *     <code>name</code>.</li>
 * <li>Finally, if the <code>object</code> implements the
 *     MBeanRegistration interface, it invokes postRegister()
 *     on the object.</li>
 * </ul>
 * @param object A reference to a MBean compliant object.
 * @param name   The ObjectName of the <code>object</code> MBean.
 * @return the actual ObjectName with which the object was registered.
 * @exception InstanceAlreadyExistsException if an object is already
 *            registered with that name.
 * @exception MBeanRegistrationException if an exception occurs during
 *            registration.
 **/
private ObjectInstance registerObject(String classname,
                                      Object object, ObjectName name)
    throws InstanceAlreadyExistsException,
           MBeanRegistrationException,
           NotCompliantMBeanException {

    if (object == null) {
        final RuntimeException wrapped =
            new IllegalArgumentException("Cannot add null object");
        throw new RuntimeOperationsException(wrapped,
                    "Exception occurred trying to register the MBean");
    }

    DynamicMBean mbean = Introspector.makeDynamicMBean(object);

    return registerDynamicMBean(classname, mbean, name);
}
 
Example 9
Source File: DefaultMBeanServerInterceptor.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Register <code>object</code> in the repository, with the
 * given <code>name</code>.
 * This method is called by the various createMBean() flavours
 * and by registerMBean() after all MBean compliance tests
 * have been performed.
 * <p>
 * This method does not performed any kind of test compliance,
 * and the caller should make sure that the given <code>object</code>
 * is MBean compliant.
 * <p>
 * This methods performed all the basic steps needed for object
 * registration:
 * <ul>
 * <li>If the <code>object</code> implements the MBeanRegistration
 *     interface, it invokes preRegister() on the object.</li>
 * <li>Then the object is added to the repository with the given
 *     <code>name</code>.</li>
 * <li>Finally, if the <code>object</code> implements the
 *     MBeanRegistration interface, it invokes postRegister()
 *     on the object.</li>
 * </ul>
 * @param object A reference to a MBean compliant object.
 * @param name   The ObjectName of the <code>object</code> MBean.
 * @return the actual ObjectName with which the object was registered.
 * @exception InstanceAlreadyExistsException if an object is already
 *            registered with that name.
 * @exception MBeanRegistrationException if an exception occurs during
 *            registration.
 **/
private ObjectInstance registerObject(String classname,
                                      Object object, ObjectName name)
    throws InstanceAlreadyExistsException,
           MBeanRegistrationException,
           NotCompliantMBeanException {

    if (object == null) {
        final RuntimeException wrapped =
            new IllegalArgumentException("Cannot add null object");
        throw new RuntimeOperationsException(wrapped,
                    "Exception occurred trying to register the MBean");
    }

    DynamicMBean mbean = Introspector.makeDynamicMBean(object);

    return registerDynamicMBean(classname, mbean, name);
}
 
Example 10
Source File: DefaultMBeanServerInterceptor.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Register <code>object</code> in the repository, with the
 * given <code>name</code>.
 * This method is called by the various createMBean() flavours
 * and by registerMBean() after all MBean compliance tests
 * have been performed.
 * <p>
 * This method does not performed any kind of test compliance,
 * and the caller should make sure that the given <code>object</code>
 * is MBean compliant.
 * <p>
 * This methods performed all the basic steps needed for object
 * registration:
 * <ul>
 * <li>If the <code>object</code> implements the MBeanRegistration
 *     interface, it invokes preRegister() on the object.</li>
 * <li>Then the object is added to the repository with the given
 *     <code>name</code>.</li>
 * <li>Finally, if the <code>object</code> implements the
 *     MBeanRegistration interface, it invokes postRegister()
 *     on the object.</li>
 * </ul>
 * @param object A reference to a MBean compliant object.
 * @param name   The ObjectName of the <code>object</code> MBean.
 * @return the actual ObjectName with which the object was registered.
 * @exception InstanceAlreadyExistsException if an object is already
 *            registered with that name.
 * @exception MBeanRegistrationException if an exception occurs during
 *            registration.
 **/
private ObjectInstance registerObject(String classname,
                                      Object object, ObjectName name)
    throws InstanceAlreadyExistsException,
           MBeanRegistrationException,
           NotCompliantMBeanException {

    if (object == null) {
        final RuntimeException wrapped =
            new IllegalArgumentException("Cannot add null object");
        throw new RuntimeOperationsException(wrapped,
                    "Exception occurred trying to register the MBean");
    }

    DynamicMBean mbean = Introspector.makeDynamicMBean(object);

    return registerDynamicMBean(classname, mbean, name);
}
 
Example 11
Source File: DefaultMBeanServerInterceptor.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Register <code>object</code> in the repository, with the
 * given <code>name</code>.
 * This method is called by the various createMBean() flavours
 * and by registerMBean() after all MBean compliance tests
 * have been performed.
 * <p>
 * This method does not performed any kind of test compliance,
 * and the caller should make sure that the given <code>object</code>
 * is MBean compliant.
 * <p>
 * This methods performed all the basic steps needed for object
 * registration:
 * <ul>
 * <li>If the <code>object</code> implements the MBeanRegistration
 *     interface, it invokes preRegister() on the object.</li>
 * <li>Then the object is added to the repository with the given
 *     <code>name</code>.</li>
 * <li>Finally, if the <code>object</code> implements the
 *     MBeanRegistration interface, it invokes postRegister()
 *     on the object.</li>
 * </ul>
 * @param object A reference to a MBean compliant object.
 * @param name   The ObjectName of the <code>object</code> MBean.
 * @return the actual ObjectName with which the object was registered.
 * @exception InstanceAlreadyExistsException if an object is already
 *            registered with that name.
 * @exception MBeanRegistrationException if an exception occurs during
 *            registration.
 **/
private ObjectInstance registerObject(String classname,
                                      Object object, ObjectName name)
    throws InstanceAlreadyExistsException,
           MBeanRegistrationException,
           NotCompliantMBeanException {

    if (object == null) {
        final RuntimeException wrapped =
            new IllegalArgumentException("Cannot add null object");
        throw new RuntimeOperationsException(wrapped,
                    "Exception occurred trying to register the MBean");
    }

    DynamicMBean mbean = Introspector.makeDynamicMBean(object);

    return registerDynamicMBean(classname, mbean, name);
}
 
Example 12
Source File: DefaultMBeanServerInterceptor.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Register <code>object</code> in the repository, with the
 * given <code>name</code>.
 * This method is called by the various createMBean() flavours
 * and by registerMBean() after all MBean compliance tests
 * have been performed.
 * <p>
 * This method does not performed any kind of test compliance,
 * and the caller should make sure that the given <code>object</code>
 * is MBean compliant.
 * <p>
 * This methods performed all the basic steps needed for object
 * registration:
 * <ul>
 * <li>If the <code>object</code> implements the MBeanRegistration
 *     interface, it invokes preRegister() on the object.</li>
 * <li>Then the object is added to the repository with the given
 *     <code>name</code>.</li>
 * <li>Finally, if the <code>object</code> implements the
 *     MBeanRegistration interface, it invokes postRegister()
 *     on the object.</li>
 * </ul>
 * @param object A reference to a MBean compliant object.
 * @param name   The ObjectName of the <code>object</code> MBean.
 * @return the actual ObjectName with which the object was registered.
 * @exception InstanceAlreadyExistsException if an object is already
 *            registered with that name.
 * @exception MBeanRegistrationException if an exception occurs during
 *            registration.
 **/
private ObjectInstance registerObject(String classname,
                                      Object object, ObjectName name)
    throws InstanceAlreadyExistsException,
           MBeanRegistrationException,
           NotCompliantMBeanException {

    if (object == null) {
        final RuntimeException wrapped =
            new IllegalArgumentException("Cannot add null object");
        throw new RuntimeOperationsException(wrapped,
                    "Exception occurred trying to register the MBean");
    }

    DynamicMBean mbean = Introspector.makeDynamicMBean(object);

    return registerDynamicMBean(classname, mbean, name);
}
 
Example 13
Source File: DefaultMBeanServerInterceptor.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Register <code>object</code> in the repository, with the
 * given <code>name</code>.
 * This method is called by the various createMBean() flavours
 * and by registerMBean() after all MBean compliance tests
 * have been performed.
 * <p>
 * This method does not performed any kind of test compliance,
 * and the caller should make sure that the given <code>object</code>
 * is MBean compliant.
 * <p>
 * This methods performed all the basic steps needed for object
 * registration:
 * <ul>
 * <li>If the <code>object</code> implements the MBeanRegistration
 *     interface, it invokes preRegister() on the object.</li>
 * <li>Then the object is added to the repository with the given
 *     <code>name</code>.</li>
 * <li>Finally, if the <code>object</code> implements the
 *     MBeanRegistration interface, it invokes postRegister()
 *     on the object.</li>
 * </ul>
 * @param object A reference to a MBean compliant object.
 * @param name   The ObjectName of the <code>object</code> MBean.
 * @return the actual ObjectName with which the object was registered.
 * @exception InstanceAlreadyExistsException if an object is already
 *            registered with that name.
 * @exception MBeanRegistrationException if an exception occurs during
 *            registration.
 **/
private ObjectInstance registerObject(String classname,
                                      Object object, ObjectName name)
    throws InstanceAlreadyExistsException,
           MBeanRegistrationException,
           NotCompliantMBeanException {

    if (object == null) {
        final RuntimeException wrapped =
            new IllegalArgumentException("Cannot add null object");
        throw new RuntimeOperationsException(wrapped,
                    "Exception occurred trying to register the MBean");
    }

    DynamicMBean mbean = Introspector.makeDynamicMBean(object);

    return registerDynamicMBean(classname, mbean, name);
}
 
Example 14
Source File: DefaultMBeanServerInterceptor.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Register <code>object</code> in the repository, with the
 * given <code>name</code>.
 * This method is called by the various createMBean() flavours
 * and by registerMBean() after all MBean compliance tests
 * have been performed.
 * <p>
 * This method does not performed any kind of test compliance,
 * and the caller should make sure that the given <code>object</code>
 * is MBean compliant.
 * <p>
 * This methods performed all the basic steps needed for object
 * registration:
 * <ul>
 * <li>If the <code>object</code> implements the MBeanRegistration
 *     interface, it invokes preRegister() on the object.</li>
 * <li>Then the object is added to the repository with the given
 *     <code>name</code>.</li>
 * <li>Finally, if the <code>object</code> implements the
 *     MBeanRegistration interface, it invokes postRegister()
 *     on the object.</li>
 * </ul>
 * @param object A reference to a MBean compliant object.
 * @param name   The ObjectName of the <code>object</code> MBean.
 * @return the actual ObjectName with which the object was registered.
 * @exception InstanceAlreadyExistsException if an object is already
 *            registered with that name.
 * @exception MBeanRegistrationException if an exception occurs during
 *            registration.
 **/
private ObjectInstance registerObject(String classname,
                                      Object object, ObjectName name)
    throws InstanceAlreadyExistsException,
           MBeanRegistrationException,
           NotCompliantMBeanException {

    if (object == null) {
        final RuntimeException wrapped =
            new IllegalArgumentException("Cannot add null object");
        throw new RuntimeOperationsException(wrapped,
                    "Exception occurred trying to register the MBean");
    }

    DynamicMBean mbean = Introspector.makeDynamicMBean(object);

    return registerDynamicMBean(classname, mbean, name);
}
 
Example 15
Source File: DefaultMBeanServerInterceptor.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Register <code>object</code> in the repository, with the
 * given <code>name</code>.
 * This method is called by the various createMBean() flavours
 * and by registerMBean() after all MBean compliance tests
 * have been performed.
 * <p>
 * This method does not performed any kind of test compliance,
 * and the caller should make sure that the given <code>object</code>
 * is MBean compliant.
 * <p>
 * This methods performed all the basic steps needed for object
 * registration:
 * <ul>
 * <li>If the <code>object</code> implements the MBeanRegistration
 *     interface, it invokes preRegister() on the object.</li>
 * <li>Then the object is added to the repository with the given
 *     <code>name</code>.</li>
 * <li>Finally, if the <code>object</code> implements the
 *     MBeanRegistration interface, it invokes postRegister()
 *     on the object.</li>
 * </ul>
 * @param object A reference to a MBean compliant object.
 * @param name   The ObjectName of the <code>object</code> MBean.
 * @return the actual ObjectName with which the object was registered.
 * @exception InstanceAlreadyExistsException if an object is already
 *            registered with that name.
 * @exception MBeanRegistrationException if an exception occurs during
 *            registration.
 **/
private ObjectInstance registerObject(String classname,
                                      Object object, ObjectName name)
    throws InstanceAlreadyExistsException,
           MBeanRegistrationException,
           NotCompliantMBeanException {

    if (object == null) {
        final RuntimeException wrapped =
            new IllegalArgumentException("Cannot add null object");
        throw new RuntimeOperationsException(wrapped,
                    "Exception occurred trying to register the MBean");
    }

    DynamicMBean mbean = Introspector.makeDynamicMBean(object);

    return registerDynamicMBean(classname, mbean, name);
}