Finish bumping to yangtools 2.1.8
[netconf.git] / netconf / netconf-impl / src / main / java / org / opendaylight / netconf / impl / osgi / NetconfImplActivator.java
index 9d520bea56b82da45857f9e4029c24882d69762c..8529da681dcd438e4840fa79a6bbd43f332c2c21 100644 (file)
@@ -23,7 +23,7 @@ import org.opendaylight.netconf.impl.SessionIdProvider;
 import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactoryListener;
 import org.opendaylight.netconf.notifications.BaseNotificationPublisherRegistration;
 import org.opendaylight.netconf.notifications.NetconfNotificationCollector;
-import org.opendaylight.netconf.util.osgi.NetconfConfigUtil;
+import org.opendaylight.netconf.util.NetconfConfiguration;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
@@ -44,6 +44,7 @@ public class NetconfImplActivator implements BundleActivator {
 
     private BaseNotificationPublisherRegistration listenerReg;
 
+    @SuppressWarnings("checkstyle:IllegalCatch")
     @Override
     public void start(final BundleContext context) {
         try {
@@ -52,62 +53,73 @@ public class NetconfImplActivator implements BundleActivator {
 
             SessionIdProvider idProvider = new SessionIdProvider();
             timer = new HashedWheelTimer();
-            long connectionTimeoutMillis = NetconfConfigUtil.extractTimeoutMillis(context);
+
+            long connectionTimeoutMillis = NetconfConfiguration.DEFAULT_TIMEOUT_MILLIS;
 
             final NetconfMonitoringServiceImpl monitoringService = startMonitoringService(context, factoriesListener);
 
-            NetconfServerSessionNegotiatorFactory serverNegotiatorFactory = new NetconfServerSessionNegotiatorFactoryBuilder()
-                    .setAggregatedOpService(factoriesListener)
-                    .setTimer(timer)
-                    .setIdProvider(idProvider)
-                    .setMonitoringService(monitoringService)
-                    .setConnectionTimeoutMillis(connectionTimeoutMillis)
-                    .build();
+            NetconfServerSessionNegotiatorFactory serverNegotiatorFactory =
+                    new NetconfServerSessionNegotiatorFactoryBuilder()
+                            .setAggregatedOpService(factoriesListener)
+                            .setTimer(timer)
+                            .setIdProvider(idProvider)
+                            .setMonitoringService(monitoringService)
+                            .setConnectionTimeoutMillis(connectionTimeoutMillis)
+                            .build();
 
             eventLoopGroup = new NioEventLoopGroup();
 
             ServerChannelInitializer serverChannelInitializer = new ServerChannelInitializer(
                     serverNegotiatorFactory);
-            NetconfServerDispatcherImpl dispatch = new NetconfServerDispatcherImpl(serverChannelInitializer, eventLoopGroup, eventLoopGroup);
+            NetconfServerDispatcherImpl dispatch = new NetconfServerDispatcherImpl(serverChannelInitializer,
+                    eventLoopGroup, eventLoopGroup);
 
-            LocalAddress address = NetconfConfigUtil.getNetconfLocalAddress();
+            LocalAddress address = NetconfConfiguration.NETCONF_LOCAL_ADDRESS;
             LOG.trace("Starting local netconf server at {}", address);
             dispatch.createLocalServer(address);
 
-            final ServiceTracker<NetconfNotificationCollector, NetconfNotificationCollector> notificationServiceTracker =
-                    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 void modifiedService(ServiceReference<NetconfNotificationCollector> reference, NetconfNotificationCollector service) {
-
-                        }
-
-                        @Override
-                        public void removedService(ServiceReference<NetconfNotificationCollector> reference, NetconfNotificationCollector service) {
-                            listenerReg.close();
-                            listenerReg = null;
-                            monitoringService.setNotificationPublisher(listenerReg);
-                        }
-                    });
+            final ServiceTracker<NetconfNotificationCollector, NetconfNotificationCollector>
+                    notificationServiceTracker = 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 void modifiedService(ServiceReference<NetconfNotificationCollector> reference,
+                                            NetconfNotificationCollector service) {
+
+                                }
+
+                            @Override
+                            public void removedService(ServiceReference<NetconfNotificationCollector> reference,
+                                           NetconfNotificationCollector service) {
+                                listenerReg.close();
+                                listenerReg = null;
+                                monitoringService.setNotificationPublisher(listenerReg);
+                            }
+                        });
             notificationServiceTracker.open();
         } catch (Exception e) {
             LOG.warn("Unable to start NetconfImplActivator", e);
         }
     }
 
-    private void startOperationServiceFactoryTracker(BundleContext context, NetconfOperationServiceFactoryListener factoriesListener) {
+    private void startOperationServiceFactoryTracker(BundleContext context,
+                                                     NetconfOperationServiceFactoryListener factoriesListener) {
         factoriesTracker = new NetconfOperationServiceFactoryTracker(context, factoriesListener);
         factoriesTracker.open();
     }
 
-    private NetconfMonitoringServiceImpl startMonitoringService(BundleContext context, AggregatedNetconfOperationServiceFactory factoriesListener) {
+    private NetconfMonitoringServiceImpl startMonitoringService(
+            BundleContext context,
+            AggregatedNetconfOperationServiceFactory factoriesListener) {
         NetconfMonitoringServiceImpl netconfMonitoringServiceImpl = new NetconfMonitoringServiceImpl(factoriesListener);
         Dictionary<String, ?> dic = new Hashtable<>();
         regMonitoring = context.registerService(NetconfMonitoringService.class, netconfMonitoringServiceImpl, dic);