2 * Copyright (c) 2014 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.controller.netconf.client;
10 import io.netty.channel.Channel;
11 import io.netty.util.concurrent.Promise;
12 import org.opendaylight.controller.netconf.nettyutil.AbstractChannelInitializer;
13 import org.opendaylight.protocol.framework.SessionListenerFactory;
15 class TcpClientChannelInitializer extends AbstractChannelInitializer<NetconfClientSession> {
17 private final NetconfClientSessionNegotiatorFactory negotiatorFactory;
18 private final NetconfClientSessionListener sessionListener;
20 TcpClientChannelInitializer(final NetconfClientSessionNegotiatorFactory negotiatorFactory,
21 final NetconfClientSessionListener sessionListener) {
22 this.negotiatorFactory = negotiatorFactory;
23 this.sessionListener = sessionListener;
27 protected void initializeSessionNegotiator(final Channel ch, final Promise<NetconfClientSession> promise) {
28 ch.pipeline().addAfter(NETCONF_MESSAGE_DECODER, AbstractChannelInitializer.NETCONF_SESSION_NEGOTIATOR,
29 negotiatorFactory.getSessionNegotiator(new SessionListenerFactory<NetconfClientSessionListener>() {
31 public NetconfClientSessionListener getSessionListener() {
32 return sessionListener;