XmlMqBuilder.java 文件源码

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

项目:tangyuan2 作者:
private void buildHostNodes(List<XmlNodeWrapper> contexts) throws Throwable {

        if (0 == contexts.size()) {
            throw new XmlParseException("Missing <mqSource> node.");
        }

        for (XmlNodeWrapper xNode : contexts) {
            String id = StringUtils.trim(xNode.getStringAttribute("id"));
            if (context.getMqSourceMap().containsKey(id)) {
                throw new XmlParseException("Duplicate <mqSource> id: " + id);
            }

            MqSourceType type = null;
            String _type = StringUtils.trim(xNode.getStringAttribute("type"));
            type = getMqSourceType(_type);
            if (null == type) {
                throw new XmlParseException("Unsupported MQ types in <mqSource>: " + id);
            }

            boolean defaultMs = false;
            String _isDefault = StringUtils.trim(xNode.getStringAttribute("isDefault"));
            if (null != _isDefault) {
                defaultMs = Boolean.parseBoolean(_isDefault);
                if (defaultMs) {
                    if (null != this.defaultMqSource) {
                        throw new XMLParseException("The default mqSource can only have one");
                    }
                    this.defaultMqSource = id;
                }
            }

            Map<String, String> data = new HashMap<String, String>();
            List<XmlNodeWrapper> properties = xNode.evalNodes("property");
            for (XmlNodeWrapper propertyNode : properties) {
                data.put(StringUtils.trim(propertyNode.getStringAttribute("name")).toUpperCase(),
                        StringUtils.trim(propertyNode.getStringAttribute("value")));
            }
            MqSourceVo hostVo = new MqSourceVo(id, type, data);
            context.getMqSourceMap().put(id, hostVo);
            log.info("add mq source: " + id);
        }

        this.context.setDefaultMqSource(defaultMqSource);

        MqSourceManager manager = new MqManagerCreater().create(defaultMqSource, context.getMqSourceMap());
        MqContainer.getInstance().setMqSourceManager(manager);
    }
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号