Example usage for javax.management JMX isMXBeanInterface

List of usage examples for javax.management JMX isMXBeanInterface

Introduction

In this page you can find the example usage for javax.management JMX isMXBeanInterface.

Prototype

public static boolean isMXBeanInterface(Class<?> interfaceClass) 

Source Link

Document

Test whether an interface is an MXBean interface.

Usage

From source file:org.opendaylight.infrautils.diagstatus.MBeanUtils.java

private static <T> T getMBean(String jmxName, Class<T> klass, MBeanServerConnection mbsc)
        throws MalformedObjectNameException {
    ObjectName objectName = new ObjectName(jmxName);
    if (JMX.isMXBeanInterface(klass)) {
        return JMX.newMXBeanProxy(mbsc, objectName, klass);
    } else {/*from   w ww. ja v a  2 s  .c om*/
        return JMX.newMBeanProxy(mbsc, objectName, klass);
    }
}

From source file:org.springframework.jmx.access.MBeanClientInterceptor.java

/**
 * Ensures that an {@code MBeanServerConnection} is configured and attempts
 * to detect a local connection if one is not supplied.
 *//*from w  w w .  j av a  2 s  .co m*/
public void prepare() {
    synchronized (this.preparationMonitor) {
        if (this.server != null) {
            this.serverToUse = this.server;
        } else {
            this.serverToUse = null;
            this.serverToUse = this.connector.connect(this.serviceUrl, this.environment, this.agentId);
        }
        this.invocationHandler = null;
        if (this.useStrictCasing) {
            Assert.state(this.objectName != null, "No ObjectName set");
            // Use the JDK's own MBeanServerInvocationHandler, in particular for native MXBean support.
            this.invocationHandler = new MBeanServerInvocationHandler(this.serverToUse, this.objectName,
                    (this.managementInterface != null && JMX.isMXBeanInterface(this.managementInterface)));
        } else {
            // Non-strict casing can only be achieved through custom invocation handling.
            // Only partial MXBean support available!
            retrieveMBeanInfo(this.serverToUse);
        }
    }
}

From source file:org.springframework.jmx.support.JmxUtils.java

/**
 * Return the Java 6 MXBean interface exists for the given class, if any
 * (that is, an interface whose name ends with "MXBean" and/or
 * carries an appropriate MXBean annotation).
 * @param clazz the class to check//  w  w  w. j  a v a 2 s . co  m
 * @return whether there is an MXBean interface for the given class
 */
@Nullable
public static Class<?> getMXBeanInterface(@Nullable Class<?> clazz) {
    if (clazz == null || clazz.getSuperclass() == null) {
        return null;
    }
    Class<?>[] implementedInterfaces = clazz.getInterfaces();
    for (Class<?> iface : implementedInterfaces) {
        if (JMX.isMXBeanInterface(iface)) {
            return iface;
        }
    }
    return getMXBeanInterface(clazz.getSuperclass());
}