package org.opendaylight.netconf.api.util;
+import com.google.common.collect.Sets;
+import java.util.Set;
+
/**
* These constants mark operation service factories that are auto wired with netconf endpoint
* for config subsystem
public static final String SERVICE_NAME = "name";
public static final String CONFIG_NETCONF_CONNECTOR = "config-netconf-connector";
public static final String NETCONF_MONITORING = "ietf-netconf-monitoring";
+ public static final String NETCONF_NOTIFICATION = "ietf-netconf-notifications";
+
+ public static final Set<String> CONFIG_SERVICE_MARKERS = Sets.newHashSet(SERVICE_NAME, CONFIG_NETCONF_CONNECTOR, NETCONF_MONITORING, NETCONF_NOTIFICATION);
}
*/
package org.opendaylight.netconf.impl.osgi;
+import com.google.common.base.Preconditions;
import io.netty.channel.local.LocalAddress;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.util.HashedWheelTimer;
new ServiceTracker<>(context, NetconfNotificationCollector.class, new ServiceTrackerCustomizer<NetconfNotificationCollector, NetconfNotificationCollector>() {
@Override
public NetconfNotificationCollector addingService(ServiceReference<NetconfNotificationCollector> reference) {
+ Preconditions.checkState(listenerReg != null, "Notification collector service was already added");
listenerReg = context.getService(reference).registerBaseNotificationPublisher();
monitoringService.setNotificationPublisher(listenerReg);
return null;
@Override
public NetconfOperationServiceFactory addingService(ServiceReference<NetconfOperationServiceFactory> reference) {
Object property = reference.getProperty(NetconfConstants.SERVICE_NAME);
- if (property != null
- && (property.equals(NetconfConstants.CONFIG_NETCONF_CONNECTOR)
- || property.equals(NetconfConstants.NETCONF_MONITORING))) {
+ if (property != null && isMarkedForConfig(property)) {
NetconfOperationServiceFactory netconfOperationServiceFactory = super.addingService(reference);
factoriesListener.onAddNetconfOperationServiceFactory(netconfOperationServiceFactory);
return netconfOperationServiceFactory;
}
}
+ private boolean isMarkedForConfig(Object property) {
+ return NetconfConstants.CONFIG_SERVICE_MARKERS.contains(property);
+ }
+
}
@Override
public void start(final BundleContext context) throws Exception {
netconfNotificationManager = new NetconfNotificationManager();
+ // Add properties to autowire with netconf-impl instance for cfg subsystem
+ final Dictionary<String, String> props = new Hashtable<>();
+ props.put(NetconfConstants.SERVICE_NAME, NetconfConstants.NETCONF_NOTIFICATION);
netconfNotificationCollectorServiceRegistration = context.registerService(NetconfNotificationCollector.class, netconfNotificationManager, new Hashtable<String, Object>());
final NetconfOperationServiceFactory netconfOperationServiceFactory = new NetconfOperationServiceFactory() {