Example usage for javax.management MBeanServerConnection createMBean

List of usage examples for javax.management MBeanServerConnection createMBean

Introduction

In this page you can find the example usage for javax.management MBeanServerConnection createMBean.

Prototype

public ObjectInstance createMBean(String className, ObjectName name)
        throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException,
        NotCompliantMBeanException, IOException;

Source Link

Document

Instantiates and registers an MBean in the MBean server.

Usage

From source file:org.helios.collector.jmx.connection.AbstractMBeanServerConnectionFactory.java

/**
 * Instantiates and registers an MBean in the MBean server.
 * @param className//from   ww  w .  jav a  2s  . com
 * @param objectName
 * @return the ObjectInstance representing the created MBean
 * @throws ReflectionException
 * @throws InstanceAlreadyExistsException
 * @throws MBeanRegistrationException
 * @throws MBeanException
 * @throws NotCompliantMBeanException
 * @throws IOException
 */
@Override
@ManagedOperation
public ObjectInstance createMBean(String className, ObjectName objectName)
        throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException,
        NotCompliantMBeanException, IOException {
    validateConn();
    MBeanServerConnection conn = null;
    try {
        conn = getPooledConnection();
        return conn.createMBean(className, objectName);
    } catch (MBeanServerConnectionFactoryException e) {
        throw new RuntimeException("Failed to get pooled connection", e);
    } finally {
        try {
            this.returnPooledConnection(conn);
        } catch (Exception e) {
            log.debug(e.getMessage());
        }
    }
}