InstanceConfig.java 文件源码

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

项目:hashsdn-controller 作者:
@SuppressWarnings("IllegalCatch")
private Map<String, Object> getMappedConfiguration(final ObjectName on, final EnumResolver enumResolver) {

    // TODO make field, mappingStrategies can be instantiated only once
    Map<String, AttributeMappingStrategy<?, ? extends OpenType<?>>> mappingStrategies = new ObjectMapper()
            .prepareMapping(jmxToAttrConfig, enumResolver);

    Map<String, Object> toXml = Maps.newHashMap();

    for (Entry<String, AttributeIfc> configDefEntry : jmxToAttrConfig.entrySet()) {
        // Skip children runtime beans as they are mapped by InstanceRuntime
        if (configDefEntry.getValue() instanceof RuntimeBeanEntry) {
            continue;
        }
        Object value = configRegistryClient.getAttributeCurrentValue(on, configDefEntry.getKey());
        try {
            AttributeMappingStrategy<?, ? extends OpenType<?>> attributeMappingStrategy = mappingStrategies
                    .get(configDefEntry.getKey());
            Optional<?> attribute = attributeMappingStrategy.mapAttribute(value);
            if (!attribute.isPresent()) {
                continue;
            }
            toXml.put(configDefEntry.getValue().getAttributeYangName(), attribute.get());
        } catch (final RuntimeException e) {
            throw new IllegalStateException("Unable to map value " + value + " to attribute "
                    + configDefEntry.getKey(), e);
        }
    }
    return toXml;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号