2 * Copyright (c) 2019 PANTHEON.tech, s.r.o. 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.nettyutil.handler.ssh.client;
10 import static java.util.Objects.requireNonNull;
12 import io.netty.channel.ChannelHandlerContext;
13 import io.netty.channel.ChannelPipeline;
14 import java.io.IOException;
15 import org.opendaylight.netconf.shaded.sshd.client.ClientFactoryManager;
16 import org.opendaylight.netconf.shaded.sshd.client.channel.ChannelSubsystem;
17 import org.opendaylight.netconf.shaded.sshd.client.session.ClientSessionImpl;
18 import org.opendaylight.netconf.shaded.sshd.common.io.IoSession;
21 * A {@link ClientSessionImpl} which additionally allows creation of NETCONF subsystem channel, which is routed to
22 * a particular {@link ChannelHandlerContext}.
24 @Deprecated(since = "7.0.0", forRemoval = true)
25 public final class NetconfClientSessionImpl extends ClientSessionImpl implements NettyAwareClientSession {
26 public NetconfClientSessionImpl(final ClientFactoryManager client, final IoSession ioSession) throws Exception {
27 super(client, ioSession);
31 public ChannelSubsystem createSubsystemChannel(final String subsystem, final ChannelHandlerContext ctx)
34 return registerSubsystem(new NettyChannelSubsystem(subsystem) {
36 ChannelHandlerContext context() {
43 public ChannelSubsystem createSubsystemChannel(final String subsystem,
44 final ChannelPipeline pipeline) throws IOException {
45 requireNonNull(pipeline);
46 return registerSubsystem(new NettyChannelSubsystem(subsystem) {
48 ChannelHandlerContext context() {
49 return pipeline.firstContext();
54 private ChannelSubsystem registerSubsystem(final ChannelSubsystem subsystem) throws IOException {
55 final var service = getConnectionService();
56 final var id = service.registerChannel(subsystem);
57 if (log.isDebugEnabled()) {
58 log.debug("createSubsystemChannel({})[{}] created id={}", this, subsystem.getSubsystem(), id);