Move NetconfMapperAggregator
[netconf.git] / apps / netconf-nb / src / main / java / org / opendaylight / netconf / northbound / DefaultNetconfServerDispatcher.java
1 /*
2  * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.netconf.northbound;
9
10 import static java.util.Objects.requireNonNull;
11
12 import io.netty.channel.EventLoopGroup;
13 import java.util.Map;
14 import org.opendaylight.netconf.server.NetconfServerDispatcherImpl;
15 import org.opendaylight.netconf.server.ServerChannelInitializer;
16 import org.opendaylight.netconf.server.api.NetconfServerDispatcher;
17 import org.osgi.service.component.annotations.Activate;
18 import org.osgi.service.component.annotations.Component;
19
20 @Component(factory = DefaultNetconfServerDispatcher.FACTORY_NAME, service = NetconfServerDispatcher.class)
21 public final class DefaultNetconfServerDispatcher extends NetconfServerDispatcherImpl {
22     static final String FACTORY_NAME = "org.opendaylight.netconf.impl.mdsal.DefaultNetconfServerDispatcher";
23
24     private static final String BOSS_PROP = ".bossGroup";
25     private static final String WORKER_PROP = ".workerGroup";
26     private static final String INITIALIZER_PROP = ".initializer";
27
28     @Activate
29     public DefaultNetconfServerDispatcher(final Map<String, ?> properties) {
30         super(OSGiNetconfServer.extractProp(properties, INITIALIZER_PROP, ServerChannelInitializer.class),
31             OSGiNetconfServer.extractProp(properties, BOSS_PROP, EventLoopGroup.class),
32             OSGiNetconfServer.extractProp(properties, WORKER_PROP, EventLoopGroup.class));
33     }
34
35     static Map<String, ?> props(final EventLoopGroup bossGroup, final EventLoopGroup workerGroup,
36             final ServerChannelInitializer initializer) {
37         return Map.of(
38             "type", "netconf-server-dispatcher",
39             BOSS_PROP, requireNonNull(bossGroup),
40             WORKER_PROP, requireNonNull(workerGroup),
41             INITIALIZER_PROP, requireNonNull(initializer));
42     }
43 }