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
8 package org.opendaylight.netconf.callhome.protocol;
10 import io.netty.channel.Channel;
11 import io.netty.util.concurrent.Promise;
12 import org.opendaylight.netconf.api.NetconfSessionListenerFactory;
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;
18 final class ReverseSshChannelInitializer extends AbstractChannelInitializer<NetconfClientSession>
19 implements NetconfSessionListenerFactory<NetconfClientSessionListener> {
21 private final NetconfClientSessionNegotiatorFactory negotiatorFactory;
22 private final NetconfClientSessionListener sessionListener;
24 private ReverseSshChannelInitializer(NetconfClientSessionNegotiatorFactory negotiatorFactory,
25 NetconfClientSessionListener sessionListener) {
26 this.negotiatorFactory = negotiatorFactory;
27 this.sessionListener = sessionListener;
30 public static ReverseSshChannelInitializer create(NetconfClientSessionNegotiatorFactory negotiatorFactory,
31 NetconfClientSessionListener listener) {
32 return new ReverseSshChannelInitializer(negotiatorFactory, listener);
36 public NetconfClientSessionListener getSessionListener() {
37 return sessionListener;
41 protected void initializeSessionNegotiator(Channel ch, Promise<NetconfClientSession> promise) {
42 ch.pipeline().addAfter(NETCONF_MESSAGE_DECODER, AbstractChannelInitializer.NETCONF_SESSION_NEGOTIATOR,
43 negotiatorFactory.getSessionNegotiator(this, ch, promise));