MBeanService.java 文件源码

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

项目:lunchy 作者:
public static void copyAllAttributes(ObjectName on, JsonObject targetObject) {
    try {
        MBeanInfo mbi = mbs.getMBeanInfo(on);
        for (MBeanAttributeInfo mbai : mbi.getAttributes()) {
            Object attValue = mbs.getAttribute(on, mbai.getName());
            if (attValue instanceof Boolean) {
                targetObject.addProperty(mbai.getName(), (Boolean) attValue);
            } else if (attValue instanceof Character) {
                targetObject.addProperty(mbai.getName(), (Character) attValue);
            } else if (attValue instanceof Number) {
                targetObject.addProperty(mbai.getName(), (Number) attValue);
            } else if (attValue instanceof String) {
                targetObject.addProperty(mbai.getName(), (String) attValue);
            } else {
                targetObject.addProperty("OBJECT:" + mbai.getName(), attValue != null ? attValue.toString() : "null");
            }
        }
    } catch (InstanceNotFoundException | IntrospectionException | ReflectionException | AttributeNotFoundException
            | MBeanException e) {
        log.error("Failed to query mbean", e);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号