MBeanInfoFactory.java 文件源码

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

项目:wildfly-core 作者:
private OpenMBeanParameterInfo[] getParameterInfos(ModelNode opNode) {
    if (!opNode.hasDefined(REQUEST_PROPERTIES)) {
        return EMPTY_PARAMETERS;
    }
    List<Property> propertyList = opNode.get(REQUEST_PROPERTIES).asPropertyList();
    List<OpenMBeanParameterInfo> params = new ArrayList<OpenMBeanParameterInfo>(propertyList.size());

    for (Property prop : propertyList) {
        ModelNode value = prop.getValue();
        String paramName = NameConverter.convertToCamelCase(prop.getName());

        Map<String, Object> descriptions = new HashMap<String, Object>(4);

        boolean expressionsAllowed = prop.getValue().hasDefined(EXPRESSIONS_ALLOWED) && prop.getValue().get(EXPRESSIONS_ALLOWED).asBoolean();
        descriptions.put(DESC_EXPRESSIONS_ALLOWED, String.valueOf(expressionsAllowed));

        if (!expressionsAllowed) {
            Object defaultValue = getIfExists(value, DEFAULT);
            descriptions.put(DEFAULT_VALUE_FIELD, defaultValue);
            if (value.has(ALLOWED)) {
                if (value.get(TYPE).asType()!=ModelType.LIST){
                    List<ModelNode> allowed = value.get(ALLOWED).asList();
                    descriptions.put(LEGAL_VALUES_FIELD, fromModelNodes(allowed));
                }
            } else {
                if (value.has(MIN)) {
                    Comparable minC = getIfExistsAsComparable(value, MIN);
                    if (minC instanceof Number) {
                        descriptions.put(MIN_VALUE_FIELD, minC);
                    }
                }
                if (value.has(MAX)) {
                    Comparable maxC = getIfExistsAsComparable(value, MAX);
                    if (maxC instanceof Number) {
                        descriptions.put(MAX_VALUE_FIELD, maxC);
                    }
                }
            }
        }


        params.add(
                new OpenMBeanParameterInfoSupport(
                        paramName,
                        getDescription(prop.getValue()),
                        converters.convertToMBeanType(value),
                        new ImmutableDescriptor(descriptions)));

    }
    return params.toArray(new OpenMBeanParameterInfo[params.size()]);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号