X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=netconf%2Fnetconf-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fimpl%2Fosgi%2FNetconfImplActivator.java;h=8529da681dcd438e4840fa79a6bbd43f332c2c21;hb=bd6ecc76e3076240630fd197d5cf6fd812ba8abb;hp=9d520bea56b82da45857f9e4029c24882d69762c;hpb=af130c5e03ebfae9f2682fe6c9bf2214d4419f9c;p=netconf.git diff --git a/netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/osgi/NetconfImplActivator.java b/netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/osgi/NetconfImplActivator.java index 9d520bea56..8529da681d 100644 --- a/netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/osgi/NetconfImplActivator.java +++ b/netconf/netconf-impl/src/main/java/org/opendaylight/netconf/impl/osgi/NetconfImplActivator.java @@ -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 notificationServiceTracker = - new ServiceTracker<>(context, NetconfNotificationCollector.class, new ServiceTrackerCustomizer() { - @Override - public NetconfNotificationCollector addingService(ServiceReference 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 reference, NetconfNotificationCollector service) { - - } - - @Override - public void removedService(ServiceReference reference, NetconfNotificationCollector service) { - listenerReg.close(); - listenerReg = null; - monitoringService.setNotificationPublisher(listenerReg); - } - }); + final ServiceTracker + notificationServiceTracker = new ServiceTracker<>(context, NetconfNotificationCollector.class, + new ServiceTrackerCustomizer() { + @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 reference, + NetconfNotificationCollector service) { + + } + + @Override + public void removedService(ServiceReference 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 dic = new Hashtable<>(); regMonitoring = context.registerService(NetconfMonitoringService.class, netconfMonitoringServiceImpl, dic);