Search in sources :

Example 1 with ObjectResolver

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);
        }
    }
}
Also used : OpenType(javax.management.openmbean.OpenType) AttributeResolvingStrategy(org.opendaylight.controller.config.facade.xml.mapping.attributes.resolving.AttributeResolvingStrategy) AttributeConfigElement(org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml.AttributeConfigElement) DocumentedException(org.opendaylight.controller.config.util.xml.DocumentedException) ObjectResolver(org.opendaylight.controller.config.facade.xml.mapping.attributes.resolving.ObjectResolver)

Example 2 with ObjectResolver

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);
        }
    }
}
Also used : OpenType(javax.management.openmbean.OpenType) AttributeResolvingStrategy(org.opendaylight.controller.config.facade.xml.mapping.attributes.resolving.AttributeResolvingStrategy) AttributeConfigElement(org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml.AttributeConfigElement) DocumentedException(org.opendaylight.controller.config.util.xml.DocumentedException) ObjectResolver(org.opendaylight.controller.config.facade.xml.mapping.attributes.resolving.ObjectResolver)

Aggregations

OpenType (javax.management.openmbean.OpenType)2 AttributeConfigElement (org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml.AttributeConfigElement)2 AttributeResolvingStrategy (org.opendaylight.controller.config.facade.xml.mapping.attributes.resolving.AttributeResolvingStrategy)2 ObjectResolver (org.opendaylight.controller.config.facade.xml.mapping.attributes.resolving.ObjectResolver)2 DocumentedException (org.opendaylight.controller.config.util.xml.DocumentedException)2