2 * Copyright (c) 2013 Cisco Systems, Inc and others. All rights reserved.
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
8 package org.opendaylight.netconf.server;
10 import static java.util.Objects.requireNonNull;
12 import io.netty.channel.Channel;
13 import io.netty.util.concurrent.Promise;
14 import org.opendaylight.netconf.nettyutil.AbstractChannelInitializer;
16 public final class ServerChannelInitializer extends AbstractChannelInitializer<NetconfServerSession> {
17 private static final String DESERIALIZER_EX_HANDLER_KEY = "deserializerExHandler";
19 private final NetconfServerSessionNegotiatorFactory negotiatorFactory;
21 public ServerChannelInitializer(final NetconfServerSessionNegotiatorFactory negotiatorFactory) {
22 this.negotiatorFactory = requireNonNull(negotiatorFactory);
26 protected void initializeMessageDecoder(final Channel ch) {
27 super.initializeMessageDecoder(ch);
28 ch.pipeline().addLast(DESERIALIZER_EX_HANDLER_KEY, new DeserializerExceptionHandler());
32 protected void initializeSessionNegotiator(final Channel ch, final Promise<NetconfServerSession> promise) {
33 ch.pipeline().addAfter(DESERIALIZER_EX_HANDLER_KEY, NETCONF_SESSION_NEGOTIATOR,
34 negotiatorFactory.getSessionNegotiator(ch, promise));