2 * Copyright (c) 2015, 2017 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.config.facade.xml.mapping.attributes.resolving;
11 import com.google.common.base.Optional;
12 import javax.management.ObjectName;
13 import javax.management.openmbean.SimpleType;
14 import org.opendaylight.controller.config.facade.xml.mapping.attributes.mapping.ObjectNameAttributeMappingStrategy;
15 import org.opendaylight.controller.config.facade.xml.mapping.config.ServiceRegistryWrapper;
16 import org.opendaylight.controller.config.facade.xml.util.Util;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
20 public class ObjectNameAttributeResolvingStrategy
21 extends AbstractAttributeResolvingStrategy<ObjectName, SimpleType<?>> {
23 private final ServiceRegistryWrapper serviceTracker;
24 private static final Logger LOG = LoggerFactory.getLogger(ObjectNameAttributeResolvingStrategy.class);
26 ObjectNameAttributeResolvingStrategy(final ServiceRegistryWrapper serviceTracker) {
27 super(SimpleType.OBJECTNAME);
28 this.serviceTracker = serviceTracker;
32 public Optional<ObjectName> parseAttribute(final String attrName, final Object value) {
34 return Optional.absent();
37 Util.checkType(value, ObjectNameAttributeMappingStrategy.MappedDependency.class);
39 ObjectNameAttributeMappingStrategy.MappedDependency mappedDep =
40 (ObjectNameAttributeMappingStrategy.MappedDependency) value;
41 String serviceName = mappedDep.getServiceName();
42 String refName = mappedDep.getRefName();
43 String namespace = mappedDep.getNamespace();
44 LOG.trace("Getting service instance by service name {} : {} and ref name {}", namespace, serviceName, refName);
46 ObjectName on = serviceTracker.getByServiceAndRefName(namespace, serviceName, refName);
48 LOG.debug("Attribute {} : {} parsed to type {}", attrName, value, getOpenType());
49 return Optional.of(on);