package org.opendaylight.controller.netconf.monitoring.osgi;
import com.google.common.base.Preconditions;
+import java.util.Dictionary;
import java.util.Hashtable;
import org.opendaylight.controller.netconf.api.monitoring.NetconfMonitoringService;
+import org.opendaylight.controller.netconf.api.util.NetconfConstants;
import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceFactory;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
public class NetconfMonitoringServiceTracker extends ServiceTracker<NetconfMonitoringService, NetconfMonitoringService> {
- private static final Logger logger = LoggerFactory.getLogger(NetconfMonitoringServiceTracker.class);
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfMonitoringServiceTracker.class);
private ServiceRegistration<NetconfOperationServiceFactory> reg;
+ private NetconfMonitoringActivator.NetconfMonitoringOperationServiceFactory factory;
NetconfMonitoringServiceTracker(final BundleContext context) {
super(context, NetconfMonitoringService.class, null);
final NetconfMonitoringOperationService operationService = new NetconfMonitoringOperationService(
netconfMonitoringService);
- final NetconfOperationServiceFactory factory = new NetconfMonitoringActivator.NetconfMonitoringOperationServiceFactory(
+ factory = new NetconfMonitoringActivator.NetconfMonitoringOperationServiceFactory(
operationService);
- reg = context.registerService(NetconfOperationServiceFactory.class, factory, new Hashtable<String, Object>());
+ Dictionary<String, String> properties = new Hashtable<>();
+ properties.put(NetconfConstants.SERVICE_NAME, NetconfConstants.NETCONF_MONITORING);
+ reg = context.registerService(NetconfOperationServiceFactory.class, factory, properties);
return netconfMonitoringService;
}
try {
reg.unregister();
} catch (final Exception e) {
- logger.warn("Ignoring exception while unregistering {}", reg, e);
+ LOG.warn("Ignoring exception while unregistering {}", reg, e);
}
}
+ if(factory!=null) {
+ factory.close();
+ }
}
}