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