From e913b8c6f1a1aab66f927d89ea695de9dd83934e Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Mon, 23 Oct 2023 20:48:30 +0200 Subject: [PATCH] Remove NetconfSessionNegotiatorFactory This interface is a useless abstraction, as the server-side completely ignores one of its arguments. Eliminate it, allowing both sides to do precisely what suites them. JIRA: NETCONF-590 Change-Id: I9fc2674a13622f3de7951463c462496b23cb3f4f Signed-off-by: Robert Varga --- .../nettyutil/AbstractNetconfDispatcher.java | 4 +-- .../NetconfSessionNegotiatorFactory.java | 34 ------------------- ...NetconfClientSessionNegotiatorFactory.java | 14 +++++--- ...NetconfServerSessionNegotiatorFactory.java | 17 +++------- .../server/ServerChannelInitializer.java | 2 +- 5 files changed, 16 insertions(+), 55 deletions(-) delete mode 100644 netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/NetconfSessionNegotiatorFactory.java diff --git a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfDispatcher.java b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfDispatcher.java index b53aafa7a4..653dc9180b 100644 --- a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfDispatcher.java +++ b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfDispatcher.java @@ -45,8 +45,8 @@ public abstract class AbstractNetconfDispatcher promise); } diff --git a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/NetconfSessionNegotiatorFactory.java b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/NetconfSessionNegotiatorFactory.java deleted file mode 100644 index 93997e536b..0000000000 --- a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/NetconfSessionNegotiatorFactory.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.netconf.nettyutil; - -import io.netty.channel.Channel; -import io.netty.util.concurrent.Promise; -import org.opendaylight.netconf.api.NetconfSession; -import org.opendaylight.netconf.api.NetconfSessionListener; -import org.opendaylight.netconf.api.NetconfSessionListenerFactory; - -/** - * A factory class creating SessionNegotiators. - * - * @param session type - */ -@Deprecated -public interface NetconfSessionNegotiatorFactory> { - /** - * Create a new negotiator attached to a channel, which will notify - * a promise once the negotiation completes. - * - * @param channel Underlying channel - * @param promise Promise to be notified - * @return new negotiator instance - */ - NetconfSessionNegotiator getSessionNegotiator(NetconfSessionListenerFactory factory, Channel channel, - Promise promise); -} diff --git a/protocol/netconf-client/src/main/java/org/opendaylight/netconf/client/NetconfClientSessionNegotiatorFactory.java b/protocol/netconf-client/src/main/java/org/opendaylight/netconf/client/NetconfClientSessionNegotiatorFactory.java index b1c0bc1bd7..e476f27b48 100644 --- a/protocol/netconf-client/src/main/java/org/opendaylight/netconf/client/NetconfClientSessionNegotiatorFactory.java +++ b/protocol/netconf-client/src/main/java/org/opendaylight/netconf/client/NetconfClientSessionNegotiatorFactory.java @@ -21,7 +21,6 @@ import org.opendaylight.netconf.api.NetconfSessionListenerFactory; import org.opendaylight.netconf.api.messages.HelloMessage; import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader; import org.opendaylight.netconf.nettyutil.AbstractNetconfSessionNegotiator; -import org.opendaylight.netconf.nettyutil.NetconfSessionNegotiatorFactory; import org.opendaylight.netconf.nettyutil.handler.exi.EXIParameters; import org.opendaylight.netconf.nettyutil.handler.exi.NetconfStartExiMessageProvider; import org.opendaylight.netconf.shaded.exificient.core.CodingMode; @@ -30,9 +29,7 @@ import org.opendaylight.netconf.shaded.exificient.core.exceptions.UnsupportedOpt import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class NetconfClientSessionNegotiatorFactory - implements NetconfSessionNegotiatorFactory { - +public final class NetconfClientSessionNegotiatorFactory { public static final Set EXI_CLIENT_CAPABILITIES = ImmutableSet.of( CapabilityURN.BASE, CapabilityURN.BASE_1_1, @@ -124,7 +121,14 @@ public class NetconfClientSessionNegotiatorFactory return connectionTimeoutMillis; } - @Override + /** + * Create a new negotiator attached to a channel, which will notify + * a promise once the negotiation completes. + * + * @param channel Underlying channel + * @param promise Promise to be notified + * @return new negotiator instance + */ public NetconfClientSessionNegotiator getSessionNegotiator( final NetconfSessionListenerFactory sessionListenerFactory, final Channel channel, final Promise promise) { diff --git a/protocol/netconf-server/src/main/java/org/opendaylight/netconf/server/NetconfServerSessionNegotiatorFactory.java b/protocol/netconf-server/src/main/java/org/opendaylight/netconf/server/NetconfServerSessionNegotiatorFactory.java index cbbcb246ee..307e33f6d4 100644 --- a/protocol/netconf-server/src/main/java/org/opendaylight/netconf/server/NetconfServerSessionNegotiatorFactory.java +++ b/protocol/netconf-server/src/main/java/org/opendaylight/netconf/server/NetconfServerSessionNegotiatorFactory.java @@ -18,10 +18,8 @@ import java.net.SocketAddress; import java.util.Set; import org.checkerframework.checker.index.qual.NonNegative; import org.opendaylight.netconf.api.CapabilityURN; -import org.opendaylight.netconf.api.NetconfSessionListenerFactory; import org.opendaylight.netconf.api.messages.HelloMessage; import org.opendaylight.netconf.nettyutil.AbstractNetconfSessionNegotiator; -import org.opendaylight.netconf.nettyutil.NetconfSessionNegotiatorFactory; import org.opendaylight.netconf.server.api.SessionIdProvider; import org.opendaylight.netconf.server.api.monitoring.NetconfMonitoringService; import org.opendaylight.netconf.server.api.operations.NetconfOperationService; @@ -31,9 +29,8 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.re import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Capabilities; -public class NetconfServerSessionNegotiatorFactory - implements NetconfSessionNegotiatorFactory { - +// FIXME: Non-final for testtool. Why exactly? +public class NetconfServerSessionNegotiatorFactory { public static final Set DEFAULT_BASE_CAPABILITIES = ImmutableSet.of( CapabilityURN.BASE, CapabilityURN.BASE_1_1, @@ -96,18 +93,12 @@ public class NetconfServerSessionNegotiatorFactory /** * Get session negotiator. * - * @param defunctSessionListenerFactory will not be taken into account as session listener factory can - * only be created after snapshot is opened, thus this method constructs - * proper session listener factory. * @param channel Underlying channel * @param promise Promise to be notified * @return session negotiator */ - @Deprecated - @Override - public NetconfServerSessionNegotiator getSessionNegotiator( - final NetconfSessionListenerFactory defunctSessionListenerFactory, - final Channel channel, final Promise promise) { + public NetconfServerSessionNegotiator getSessionNegotiator(final Channel channel, + final Promise promise) { final var sessionId = idProvider.getNextSessionId(); final var socketAddress = channel.parent() == null ? null : channel.parent().localAddress(); final var service = getOperationServiceForAddress(sessionId, socketAddress); diff --git a/protocol/netconf-server/src/main/java/org/opendaylight/netconf/server/ServerChannelInitializer.java b/protocol/netconf-server/src/main/java/org/opendaylight/netconf/server/ServerChannelInitializer.java index dfe858bf54..54380b2dd0 100644 --- a/protocol/netconf-server/src/main/java/org/opendaylight/netconf/server/ServerChannelInitializer.java +++ b/protocol/netconf-server/src/main/java/org/opendaylight/netconf/server/ServerChannelInitializer.java @@ -31,6 +31,6 @@ public final class ServerChannelInitializer extends AbstractChannelInitializer promise) { ch.pipeline().addAfter(DESERIALIZER_EX_HANDLER_KEY, NETCONF_SESSION_NEGOTIATOR, - negotiatorFactory.getSessionNegotiator(null, ch, promise)); + negotiatorFactory.getSessionNegotiator(ch, promise)); } } -- 2.36.6