Example usage for javax.management MBeanServerConnection isInstanceOf

List of usage examples for javax.management MBeanServerConnection isInstanceOf

Introduction

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

Prototype

public boolean isInstanceOf(ObjectName name, String className) throws InstanceNotFoundException, IOException;

Source Link

Document

Returns true if the MBean specified is an instance of the specified class, false otherwise.

If name does not name an MBean, this method throws InstanceNotFoundException .

Otherwise, let
X be the MBean named by name,
L be the ClassLoader of X,
N be the class name in X's MBeanInfo .

If N equals className, the result is true.

Otherwise, if L successfully loads className and X is an instance of this class, the result is true.

Usage

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

/**
 * Determines if the named MBean is an instance of the passed class name
 * @param objectName/*from www . j  av a2s .c om*/
 * @param className
 * @return
 * @throws InstanceNotFoundException
 * @throws IOException
 */
@Override
@ManagedOperation
public boolean isInstanceOf(ObjectName objectName, String className)
        throws InstanceNotFoundException, IOException {
    validateConn();
    MBeanServerConnection conn = null;
    try {
        conn = getPooledConnection();
        return conn.isInstanceOf(objectName, className);
    } catch (MBeanServerConnectionFactoryException e) {
        throw new RuntimeException("Failed to get pooled connection", e);
    } finally {
        try {
            this.returnPooledConnection(conn);
        } catch (Exception e) {
            log.debug(e.getMessage());
        }
    }
}