package org.opendaylight.controller.netconf.confignetconfconnector.osgi;
+import static com.google.common.base.Preconditions.checkState;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+import org.opendaylight.controller.netconf.api.util.NetconfConstants;
import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceFactory;
+import org.opendaylight.yangtools.sal.binding.generator.util.BindingRuntimeContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.Dictionary;
-import java.util.Hashtable;
-
-import static com.google.common.base.Preconditions.checkState;
-
public class Activator implements BundleActivator {
- private static final Logger logger = LoggerFactory.getLogger(Activator.class);
+ private static final Logger LOG = LoggerFactory.getLogger(Activator.class);
private BundleContext context;
private ServiceRegistration<?> osgiRegistration;
ServiceTrackerCustomizer<SchemaContextProvider, ConfigRegistryLookupThread> customizer = new ServiceTrackerCustomizer<SchemaContextProvider, ConfigRegistryLookupThread>() {
@Override
public ConfigRegistryLookupThread addingService(ServiceReference<SchemaContextProvider> reference) {
- logger.debug("Got addingService(SchemaContextProvider) event, starting ConfigRegistryLookupThread");
+ LOG.debug("Got addingService(SchemaContextProvider) event, starting ConfigRegistryLookupThread");
checkState(configRegistryLookup == null, "More than one onYangStoreAdded received");
SchemaContextProvider schemaContextProvider = reference.getBundle().getBundleContext().getService(reference);
- YangStoreServiceImpl yangStoreService = new YangStoreServiceImpl(schemaContextProvider);
+ YangStoreService yangStoreService = new YangStoreService(schemaContextProvider, context);
configRegistryLookup = new ConfigRegistryLookupThread(yangStoreService);
configRegistryLookup.start();
return configRegistryLookup;
@Override
public void modifiedService(ServiceReference<SchemaContextProvider> reference, ConfigRegistryLookupThread configRegistryLookup) {
- logger.debug("Got modifiedService(SchemaContextProvider) event");
- configRegistryLookup.yangStoreService.refresh();
+ LOG.debug("Got modifiedService(SchemaContextProvider) event");
+ final BindingRuntimeContext runtimeContext = (BindingRuntimeContext) reference.getProperty(BindingRuntimeContext.class.getName());
+ LOG.debug("BindingRuntimeContext retrieved as {}", runtimeContext);
+ configRegistryLookup.yangStoreService.refresh(runtimeContext);
}
}
private class ConfigRegistryLookupThread extends Thread {
- private final YangStoreServiceImpl yangStoreService;
+ private final YangStoreService yangStoreService;
- private ConfigRegistryLookupThread(YangStoreServiceImpl yangStoreService) {
+ private ConfigRegistryLookupThread(YangStoreService yangStoreService) {
super("config-registry-lookup");
this.yangStoreService = yangStoreService;
}
@Override
public void run() {
NetconfOperationServiceFactoryImpl factory = new NetconfOperationServiceFactoryImpl(yangStoreService);
- logger.debug("Registering into OSGi");
+ LOG.debug("Registering into OSGi");
Dictionary<String, String> properties = new Hashtable<>();
- properties.put("name", "config-netconf-connector");
+ properties.put(NetconfConstants.SERVICE_NAME, NetconfConstants.CONFIG_NETCONF_CONNECTOR);
osgiRegistration = context.registerService(NetconfOperationServiceFactory.class, factory, properties);
}
}