import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
-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;
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 serviceName, 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();
Util.checkType(value, ObjectName.class);
ObjectName on = (ObjectName) value;
- String refName = tracker.addServiceEntry(namespace, serviceName, on);
+
+ String refName = ObjectNameUtil.getReferenceName(on);
return Optional.of(new MappedDependency(namespace, serviceName, refName));
}