2 * Copyright (c) 2016 Brocade Communication Systems 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
9 package org.opendaylight.netconf.callhome.protocol;
11 import io.netty.channel.Channel;
12 import io.netty.util.concurrent.Promise;
13 import org.opendaylight.netconf.client.NetconfClientSession;
14 import org.opendaylight.netconf.client.NetconfClientSessionListener;
15 import org.opendaylight.netconf.client.NetconfClientSessionNegotiatorFactory;
16 import org.opendaylight.netconf.nettyutil.AbstractChannelInitializer;
17 import org.opendaylight.protocol.framework.SessionListenerFactory;
19 class ReverseSshChannelInitializer extends AbstractChannelInitializer<NetconfClientSession>
20 implements SessionListenerFactory<NetconfClientSessionListener> {
22 private final NetconfClientSessionNegotiatorFactory negotiatorFactory;
23 private final NetconfClientSessionListener sessionListener;
25 private ReverseSshChannelInitializer(NetconfClientSessionNegotiatorFactory negotiatorFactory,
26 NetconfClientSessionListener sessionListener) {
28 this.negotiatorFactory = negotiatorFactory;
29 this.sessionListener = sessionListener;
32 public static ReverseSshChannelInitializer create(NetconfClientSessionNegotiatorFactory negotiatorFactory,
33 NetconfClientSessionListener listener) {
34 return new ReverseSshChannelInitializer(negotiatorFactory, listener);
38 public NetconfClientSessionListener getSessionListener() {
39 return sessionListener;
43 protected void initializeSessionNegotiator(Channel ch, Promise<NetconfClientSession> promise) {
44 ch.pipeline().addAfter(NETCONF_MESSAGE_DECODER, AbstractChannelInitializer.NETCONF_SESSION_NEGOTIATOR,
45 negotiatorFactory.getSessionNegotiator(this, ch, promise));