import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
-import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.AttributesConstants;
-import org.opendaylight.controller.netconf.confignetconfconnector.mapping.config.Services;
-import org.opendaylight.controller.netconf.confignetconfconnector.util.Util;
-
import javax.management.ObjectName;
import javax.management.openmbean.SimpleType;
+import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
+import org.opendaylight.controller.netconf.confignetconfconnector.util.Util;
+import org.opendaylight.yangtools.yang.common.QName;
public class ObjectNameAttributeMappingStrategy extends
AbstractAttributeMappingStrategy<ObjectNameAttributeMappingStrategy.MappedDependency, SimpleType<?>> {
- private final Services tracker;
- private final String serviceName;
private final String namespace;
- public ObjectNameAttributeMappingStrategy(SimpleType<?> openType, Services dependencyTracker, String serviceName, String namespace) {
+ public ObjectNameAttributeMappingStrategy(SimpleType<?> openType, String namespace) {
super(openType);
- this.tracker = dependencyTracker;
- this.serviceName = serviceName;
this.namespace = namespace;
}
@Override
public Optional<MappedDependency> mapAttribute(Object value) {
- if (value == null)
+ if (value == null){
return Optional.absent();
+ }
String expectedClass = getOpenType().getClassName();
String realClass = value.getClass().getName();
ObjectName on = (ObjectName) value;
- String expectedRefName = on.getKeyProperty(AttributesConstants.REF_NAME_ON_PROPERTY_KEY);
-
- String refName = expectedRefName == null ? tracker.getRefName(namespace, serviceName, on, Optional.<String> absent())
- : tracker.getRefName(namespace, serviceName, on, Optional.of(expectedRefName));
+ String refName = ObjectNameUtil.getReferenceName(on);
- return Optional.of(new MappedDependency(namespace, serviceName, refName));
+ //we want to use the exact service name that was configured in xml so services that are referencing it can be resolved
+ return Optional.of(new MappedDependency(namespace,
+ QName.create(ObjectNameUtil.getServiceQName(on)).getLocalName(), refName));
}
public static class MappedDependency {