Merge "BUG 2676 : Use notification-dispatcher for DataChangeListener actors"
[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.api.monitoring.NetconfMonitoringService;
5 import org.opendaylight.controller.netconf.impl.CommitNotifier;
6 import org.opendaylight.controller.netconf.impl.NetconfServerDispatcherImpl;
7 import org.opendaylight.controller.netconf.impl.NetconfServerSessionNegotiatorFactory;
8 import org.opendaylight.controller.netconf.impl.SessionIdProvider;
9 import org.opendaylight.controller.netconf.impl.osgi.AggregatedNetconfOperationServiceFactory;
10 import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceFactory;
11
12 public class NetconfServerDispatcherModule extends org.opendaylight.controller.config.yang.config.netconf.northbound.impl.AbstractNetconfServerDispatcherModule {
13     public NetconfServerDispatcherModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
14         super(identifier, dependencyResolver);
15     }
16
17     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) {
18         super(identifier, dependencyResolver, oldModule, oldInstance);
19     }
20
21     @Override
22     public void customValidation() {
23         JmxAttributeValidationException.checkCondition(getConnectionTimeoutMillis() > 0, "Invalid connection timeout", connectionTimeoutMillisJmxAttribute);
24     }
25
26     @Override
27     public java.lang.AutoCloseable createInstance() {
28
29         final AggregatedNetconfOperationServiceFactory aggregatedOpProvider = getAggregatedOpProvider();
30         final NetconfMonitoringService monitoringService = getServerMonitorDependency();
31         final NetconfServerSessionNegotiatorFactory serverNegotiatorFactory = new NetconfServerSessionNegotiatorFactory(
32                 getTimerDependency(), aggregatedOpProvider, new SessionIdProvider(), getConnectionTimeoutMillis(), CommitNotifier.NoopCommitNotifier.getInstance(), monitoringService);
33         final NetconfServerDispatcherImpl.ServerChannelInitializer serverChannelInitializer = new NetconfServerDispatcherImpl.ServerChannelInitializer(
34                 serverNegotiatorFactory);
35
36         return new NetconfServerDispatcherImpl(serverChannelInitializer, getBossThreadGroupDependency(), getWorkerThreadGroupDependency()) {
37
38             @Override
39             public void close() {
40                 // NOOP, close should not be present here, the deprecated method closes injected evet loop groups
41             }
42         };
43
44     }
45
46     private AggregatedNetconfOperationServiceFactory getAggregatedOpProvider() {
47         final AggregatedNetconfOperationServiceFactory netconfOperationProvider = new AggregatedNetconfOperationServiceFactory();
48         for (final NetconfOperationServiceFactory netconfOperationServiceFactory : getMappersDependency()) {
49             netconfOperationProvider.onAddNetconfOperationServiceFactory(netconfOperationServiceFactory);
50         }
51         return netconfOperationProvider;
52     }
53
54
55 }