2 * Copyright (c) 2023 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.server;
10 import static java.util.Objects.requireNonNull;
12 import org.opendaylight.netconf.transport.api.TransportChannel;
13 import org.opendaylight.netconf.transport.api.TransportChannelListener;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
18 * A {@link TransportChannelListener} which initializes NETCONF server implementations working on top
19 * of a {@link TransportChannel}.
21 public final class ServerTransportInitializer implements TransportChannelListener {
22 private static final Logger LOG = LoggerFactory.getLogger(ServerTransportInitializer.class);
24 private final ServerChannelInitializer initializer;
26 public ServerTransportInitializer(final ServerChannelInitializer initializer) {
27 this.initializer = requireNonNull(initializer);
31 public void onTransportChannelEstablished(final TransportChannel channel) {
32 LOG.debug("Transport channel {} established", channel);
33 final var nettyChannel = channel.channel();
34 initializer.initialize(nettyChannel, nettyChannel.eventLoop().newPromise());
38 public void onTransportChannelFailed(final Throwable cause) {
39 LOG.error("Transport channel failed", cause);