Merge "Fix for Bug 2727 - Upgrade Akka from 2.3.4 to 2.3.9"
[controller.git] / opendaylight / netconf / netconf-impl / src / main / java / org / opendaylight / controller / config / yang / config / netconf / northbound / impl / NetconfServerDispatcherModule.java
1 package org.opendaylight.controller.config.yang.config.netconf.northbound.impl;
2
3 import org.opendaylight.controller.config.api.JmxAttributeValidationException;
4 import org.opendaylight.controller.netconf.impl.CommitNotifier;
5 import org.opendaylight.controller.netconf.impl.NetconfServerDispatcherImpl;
6 import org.opendaylight.controller.netconf.impl.NetconfServerSessionNegotiatorFactory;
7 import org.opendaylight.controller.netconf.impl.SessionIdProvider;
8 import org.opendaylight.controller.netconf.impl.osgi.NetconfMonitoringServiceImpl;
9 import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceFactoryListenerImpl;
10 import org.opendaylight.controller.netconf.impl.osgi.SessionMonitoringService;
11 import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceFactory;
12
13 public class NetconfServerDispatcherModule extends org.opendaylight.controller.config.yang.config.netconf.northbound.impl.AbstractNetconfServerDispatcherModule {
14     public NetconfServerDispatcherModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
15         super(identifier, dependencyResolver);
16     }
17
18     public NetconfServerDispatcherModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.config.netconf.northbound.impl.NetconfServerDispatcherModule oldModule, java.lang.AutoCloseable oldInstance) {
19         super(identifier, dependencyResolver, oldModule, oldInstance);
20     }
21
22     @Override
23     public void customValidation() {
24         JmxAttributeValidationException.checkCondition(getConnectionTimeoutMillis() > 0, "Invalid connection timeout", connectionTimeoutMillisJmxAttribute);
25     }
26
27     @Override
28     public java.lang.AutoCloseable createInstance() {
29
30         final NetconfOperationServiceFactoryListenerImpl aggregatedOpProvider = getAggregatedOpProvider();
31         final SessionMonitoringService monitoringService = startMonitoringService(aggregatedOpProvider);
32         final NetconfServerSessionNegotiatorFactory serverNegotiatorFactory = new NetconfServerSessionNegotiatorFactory(
33                 getTimerDependency(), aggregatedOpProvider, new SessionIdProvider(), getConnectionTimeoutMillis(), CommitNotifier.NoopCommitNotifier.getInstance(), monitoringService);
34         final NetconfServerDispatcherImpl.ServerChannelInitializer serverChannelInitializer = new NetconfServerDispatcherImpl.ServerChannelInitializer(
35                 serverNegotiatorFactory);
36
37         return new NetconfServerDispatcherImpl(serverChannelInitializer, getBossThreadGroupDependency(), getWorkerThreadGroupDependency()) {
38
39             @Override
40             public void close() {
41                 // NOOP, close should not be present here, the deprecated method closes injected evet loop groups
42             }
43         };
44
45     }
46
47     private NetconfMonitoringServiceImpl startMonitoringService(final NetconfOperationServiceFactoryListenerImpl netconfOperationProvider) {
48         return new NetconfMonitoringServiceImpl(netconfOperationProvider);
49     }
50
51     private NetconfOperationServiceFactoryListenerImpl getAggregatedOpProvider() {
52         final NetconfOperationServiceFactoryListenerImpl netconfOperationProvider = new NetconfOperationServiceFactoryListenerImpl();
53         for (final NetconfOperationServiceFactory netconfOperationServiceFactory : getMappersDependency()) {
54             netconfOperationProvider.onAddNetconfOperationServiceFactory(netconfOperationServiceFactory);
55         }
56         return netconfOperationProvider;
57     }
58
59
60 }