use of org.opendaylight.controller.config.facade.xml.mapping.attributes.resolving.ObjectResolver in project controller by opendaylight.
the class InstanceRuntimeRpc method resolveConfiguration.
private void resolveConfiguration(final Map<String, AttributeConfigElement> mappedConfig) {
// TODO make field, resolvingStrategies can be instantiated only once
Map<String, AttributeResolvingStrategy<?, ? extends OpenType<?>>> resolvingStrategies = new ObjectResolver(null).prepareResolving(yangToAttrConfig, enumResolver);
// TODO make constructor for object resolver without service tracker
for (Entry<String, AttributeConfigElement> configDefEntry : mappedConfig.entrySet()) {
try {
AttributeResolvingStrategy<?, ? extends OpenType<?>> attributeResolvingStrategy = resolvingStrategies.get(configDefEntry.getKey());
configDefEntry.getValue().resolveValue(attributeResolvingStrategy, configDefEntry.getKey());
configDefEntry.getValue().setJmxName(yangToAttrConfig.get(configDefEntry.getKey()).getUpperCaseCammelCase());
} catch (final DocumentedException e) {
throw new IllegalStateException("Unable to resolve value " + configDefEntry.getValue() + " to attribute " + configDefEntry.getKey(), e);
}
}
}
use of org.opendaylight.controller.config.facade.xml.mapping.attributes.resolving.ObjectResolver in project controller by opendaylight.
the class InstanceConfig method resolveConfiguration.
private void resolveConfiguration(final InstanceConfigElementResolved mappedConfig, final ServiceRegistryWrapper depTracker, final EnumResolver enumResolver) {
// TODO make field, resolvingStrategies can be instantiated only once
Map<String, AttributeResolvingStrategy<?, ? extends OpenType<?>>> resolvingStrategies = new ObjectResolver(depTracker).prepareResolving(yangToAttrConfig, enumResolver);
for (Entry<String, AttributeConfigElement> configDefEntry : mappedConfig.getConfiguration().entrySet()) {
AttributeConfigElement value = configDefEntry.getValue();
String attributeName = configDefEntry.getKey();
try {
AttributeResolvingStrategy<?, ? extends OpenType<?>> attributeResolvingStrategy = resolvingStrategies.get(attributeName);
LOG.trace("Trying to set value {} of attribute {} with {}", value, attributeName, attributeResolvingStrategy);
value.resolveValue(attributeResolvingStrategy, attributeName);
value.setJmxName(yangToAttrConfig.get(attributeName).getUpperCaseCammelCase());
} catch (final DocumentedException e) {
throw new IllegalStateException("Unable to resolve value " + value + " to attribute " + attributeName, e);
}
}
}
Aggregations