ManagementFactory.java 文件源码

java
阅读 39 收藏 0 点赞 0 评论 0

项目:freeVM 作者:
/**
 * @param <T>
 * @param connection
 * @param mxbeanName
 * @param mxbeanInterface
 * @return a new proxy object representing the named <code>MXBean</code>.
 *         All subsequent method invocations on the proxy will be routed
 *         through the supplied {@link MBeanServerConnection} object.
 * @throws IOException
 */
@SuppressWarnings("unchecked")
public static <T> T newPlatformMXBeanProxy(MBeanServerConnection connection,
        String mxbeanName, Class<T> mxbeanInterface) throws IOException {
    // Check that the named object implements the specified interface
    verifyNamedMXBean(mxbeanName, mxbeanInterface);

    T result = null;
    Class[] interfaces = null;
    if (ManagementUtils.isANotificationEmitter(mxbeanInterface)) {
        // Proxies of the MemoryMXBean and OperatingSystemMXBean interfaces
        // must also implement the NotificationEmitter interface.
        interfaces = new Class[] { mxbeanInterface,
                NotificationEmitter.class };
    } else {
        interfaces = new Class[] { mxbeanInterface };
    }

    result = (T) Proxy.newProxyInstance(interfaces[0].getClassLoader(),
            interfaces, new OpenTypeMappingIHandler(connection,
                    mxbeanInterface.getName(), mxbeanName));
    return result;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号