当前位置: 首页>>代码示例>>Java>>正文


Java Introspector.testComplianceMXBeanInterface方法代码示例

本文整理汇总了Java中com.sun.jmx.mbeanserver.Introspector.testComplianceMXBeanInterface方法的典型用法代码示例。如果您正苦于以下问题:Java Introspector.testComplianceMXBeanInterface方法的具体用法?Java Introspector.testComplianceMXBeanInterface怎么用?Java Introspector.testComplianceMXBeanInterface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sun.jmx.mbeanserver.Introspector的用法示例。


在下文中一共展示了Introspector.testComplianceMXBeanInterface方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createProxy

import com.sun.jmx.mbeanserver.Introspector; //导入方法依赖的package包/类
/**
 * Centralised M(X)Bean proxy creation code
 * @param connection {@linkplain MBeanServerConnection} to use
 * @param objectName M(X)Bean object name
 * @param interfaceClass M(X)Bean interface class
 * @param notificationEmitter Is a notification emitter?
 * @param isMXBean Is an MXBean?
 * @return Returns an M(X)Bean proxy generated for the provided interface class
 * @throws SecurityException
 * @throws IllegalArgumentException
 */
private static <T> T createProxy(MBeanServerConnection connection,
                                 ObjectName objectName,
                                 Class<T> interfaceClass,
                                 boolean notificationEmitter,
                                 boolean isMXBean) {

    try {
        if (isMXBean) {
            // Check interface for MXBean compliance
            Introspector.testComplianceMXBeanInterface(interfaceClass);
        } else {
            // Check interface for MBean compliance
            Introspector.testComplianceMBeanInterface(interfaceClass);
        }
    } catch (NotCompliantMBeanException e) {
        throw new IllegalArgumentException(e);
    }

    InvocationHandler handler = new MBeanServerInvocationHandler(
            connection, objectName, isMXBean);
    final Class<?>[] interfaces;
    if (notificationEmitter) {
        interfaces =
            new Class<?>[] {interfaceClass, NotificationEmitter.class};
    } else
        interfaces = new Class<?>[] {interfaceClass};

    Object proxy = Proxy.newProxyInstance(
            interfaceClass.getClassLoader(),
            interfaces,
            handler);
    return interfaceClass.cast(proxy);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:45,代码来源:JMX.java

示例2: createProxy

import com.sun.jmx.mbeanserver.Introspector; //导入方法依赖的package包/类
/**
 * Centralised M(X)Bean proxy creation code
 * @param connection {@linkplain MBeanServerConnection} to use
 * @param objectName M(X)Bean object name
 * @param interfaceClass M(X)Bean interface class
 * @param notificationEmitter Is a notification emitter?
 * @param isMXBean Is an MXBean?
 * @return Returns an M(X)Bean proxy generated for the provided interface class
 * @throws SecurityException
 * @throws IllegalArgumentException
 */
private static <T> T createProxy(MBeanServerConnection connection,
                                 ObjectName objectName,
                                 Class<T> interfaceClass,
                                 boolean notificationEmitter,
                                 boolean isMXBean) {

    if (System.getSecurityManager() != null) {
        checkProxyInterface(interfaceClass);
    }
    try {
        if (isMXBean) {
            // Check interface for MXBean compliance
            Introspector.testComplianceMXBeanInterface(interfaceClass);
        } else {
            // Check interface for MBean compliance
            Introspector.testComplianceMBeanInterface(interfaceClass);
        }
    } catch (NotCompliantMBeanException e) {
        throw new IllegalArgumentException(e);
    }

    InvocationHandler handler = new MBeanServerInvocationHandler(
            connection, objectName, isMXBean);
    final Class<?>[] interfaces;
    if (notificationEmitter) {
        interfaces =
            new Class<?>[] {interfaceClass, NotificationEmitter.class};
    } else
        interfaces = new Class<?>[] {interfaceClass};

    Object proxy = Proxy.newProxyInstance(
            interfaceClass.getClassLoader(),
            interfaces,
            handler);
    return interfaceClass.cast(proxy);
}
 
开发者ID:greghaskins,项目名称:openjdk-jdk7u-jdk,代码行数:48,代码来源:JMX.java

示例3: newMXBeanProxy

import com.sun.jmx.mbeanserver.Introspector; //导入方法依赖的package包/类
/**
 * <p>Make a proxy for an MXBean in a local or remote MBean
 * Server that may also support the methods of {@link
 * NotificationEmitter}.</p>
 *
 * <p>This method behaves the same as {@link
 * #newMXBeanProxy(MBeanServerConnection, ObjectName, Class)}, but
 * additionally, if {@code notificationEmitter} is {@code
 * true}, then the MXBean is assumed to be a {@link
 * NotificationBroadcaster} or {@link NotificationEmitter} and the
 * returned proxy will implement {@link NotificationEmitter} as
 * well as {@code interfaceClass}.  A call to {@link
 * NotificationBroadcaster#addNotificationListener} on the proxy
 * will result in a call to {@link
 * MBeanServerConnection#addNotificationListener(ObjectName,
 * NotificationListener, NotificationFilter, Object)}, and
 * likewise for the other methods of {@link
 * NotificationBroadcaster} and {@link NotificationEmitter}.</p>
 *
 * @param connection the MBean server to forward to.
 * @param objectName the name of the MBean within
 * {@code connection} to forward to.
 * @param interfaceClass the MXBean interface,
 * which will also be implemented by the returned proxy.
 * @param notificationEmitter make the returned proxy
 * implement {@link NotificationEmitter} by forwarding its methods
 * via {@code connection}.
 *
 * @param <T> allows the compiler to know that if the {@code
 * interfaceClass} parameter is {@code MyMXBean.class}, for
 * example, then the return type is {@code MyMXBean}.
 *
 * @return the new proxy instance.
 */
public static <T> T newMXBeanProxy(MBeanServerConnection connection,
                                   ObjectName objectName,
                                   Class<T> interfaceClass,
                                   boolean notificationEmitter) {
    // Check interface for MXBean compliance
    //
    try {
        Introspector.testComplianceMXBeanInterface(interfaceClass);
    } catch (NotCompliantMBeanException e) {
        throw new IllegalArgumentException(e);
    }
    InvocationHandler handler = new MBeanServerInvocationHandler(
            connection, objectName, true);
    final Class<?>[] interfaces;
    if (notificationEmitter) {
        interfaces =
            new Class<?>[] {interfaceClass, NotificationEmitter.class};
    } else
        interfaces = new Class<?>[] {interfaceClass};
    Object proxy = Proxy.newProxyInstance(
            interfaceClass.getClassLoader(),
            interfaces,
            handler);
    return interfaceClass.cast(proxy);
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:60,代码来源:JMX.java


注:本文中的com.sun.jmx.mbeanserver.Introspector.testComplianceMXBeanInterface方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。