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.impl;
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.impl.util.DeserializerExceptionHandler;
15 import org.opendaylight.netconf.nettyutil.AbstractChannelInitializer;
17 public final class ServerChannelInitializer extends AbstractChannelInitializer<NetconfServerSession> {
18 private static final String DESERIALIZER_EX_HANDLER_KEY = "deserializerExHandler";
20 private final NetconfServerSessionNegotiatorFactory negotiatorFactory;
22 public ServerChannelInitializer(final NetconfServerSessionNegotiatorFactory negotiatorFactory) {
23 this.negotiatorFactory = requireNonNull(negotiatorFactory);
27 protected void initializeMessageDecoder(final Channel ch) {
28 super.initializeMessageDecoder(ch);
29 ch.pipeline().addLast(DESERIALIZER_EX_HANDLER_KEY, new DeserializerExceptionHandler());
33 protected void initializeSessionNegotiator(final Channel ch, final Promise<NetconfServerSession> promise) {
34 ch.pipeline().addAfter(DESERIALIZER_EX_HANDLER_KEY, NETCONF_SESSION_NEGOTIATOR,
35 negotiatorFactory.getSessionNegotiator(null, ch, promise));