Remove NetconfSessionNegotiatorFactory 03/108603/7
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 23 Oct 2023 18:48:30 +0000 (20:48 +0200)
committerRobert Varga <nite@hq.sk>
Tue, 24 Oct 2023 11:41:19 +0000 (11:41 +0000)
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 <robert.varga@pantheon.tech>
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfDispatcher.java
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/NetconfSessionNegotiatorFactory.java [deleted file]
protocol/netconf-client/src/main/java/org/opendaylight/netconf/client/NetconfClientSessionNegotiatorFactory.java
protocol/netconf-server/src/main/java/org/opendaylight/netconf/server/NetconfServerSessionNegotiatorFactory.java
protocol/netconf-server/src/main/java/org/opendaylight/netconf/server/ServerChannelInitializer.java

index b53aafa7a422c69d446f45bc4f990bf299ed95dc..653dc9180b2f852e3d4ab16ec947fbf6a5c42162 100644 (file)
@@ -45,8 +45,8 @@ public abstract class AbstractNetconfDispatcher<S extends NetconfSession, L exte
          * Initializes channel by specifying the handlers in its pipeline. Handlers are protocol specific, therefore
          * this method needs to be implemented in protocol specific Dispatchers.
          *
-         * @param channel whose pipeline should be defined, also to be passed to {@link NetconfSessionNegotiatorFactory}
-         * @param promise to be passed to {@link NetconfSessionNegotiatorFactory}
+         * @param channel whose pipeline should be defined, also to be passed to {@link NetconfSessionNegotiator}
+         * @param promise to be passed to {@link NetconfSessionNegotiator}
          */
         void initializeChannel(C channel, Promise<S> 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 (file)
index 93997e5..0000000
+++ /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 <S> session type
- */
-@Deprecated
-public interface NetconfSessionNegotiatorFactory<S extends NetconfSession,
-        L extends NetconfSessionListener<? super S>> {
-    /**
-     * 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<S> getSessionNegotiator(NetconfSessionListenerFactory<L> factory, Channel channel,
-            Promise<S> promise);
-}
index b1c0bc1bd7d71b72be42e7cb16448ca0062cbef5..e476f27b484cc760aa45237e38bbdd99f46ec95b 100644 (file)
@@ -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<NetconfClientSession, NetconfClientSessionListener> {
-
+public final class NetconfClientSessionNegotiatorFactory {
     public static final Set<String> 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<NetconfClientSessionListener> sessionListenerFactory,
             final Channel channel, final Promise<NetconfClientSession> promise) {
index cbbcb246eeac482c83ea95887a9f00b97e1c9bad..307e33f6d420251d2fa8629040d086c928a8ee40 100644 (file)
@@ -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<NetconfServerSession, NetconfServerSessionListener> {
-
+// FIXME: Non-final for testtool. Why exactly?
+public class NetconfServerSessionNegotiatorFactory {
     public static final Set<String> 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<NetconfServerSessionListener> defunctSessionListenerFactory,
-            final Channel channel, final Promise<NetconfServerSession> promise) {
+    public NetconfServerSessionNegotiator getSessionNegotiator(final Channel channel,
+            final Promise<NetconfServerSession> promise) {
         final var sessionId = idProvider.getNextSessionId();
         final var socketAddress = channel.parent() == null ? null : channel.parent().localAddress();
         final var service = getOperationServiceForAddress(sessionId, socketAddress);
index dfe858bf547b70a89b4382e9c7b819fa327f722d..54380b2dd02f37a9912ae6e2ed1ee29e69e51891 100644 (file)
@@ -31,6 +31,6 @@ public final class ServerChannelInitializer extends AbstractChannelInitializer<N
     @Override
     protected void initializeSessionNegotiator(final Channel ch, final Promise<NetconfServerSession> promise) {
         ch.pipeline().addAfter(DESERIALIZER_EX_HANDLER_KEY, NETCONF_SESSION_NEGOTIATOR,
-            negotiatorFactory.getSessionNegotiator(null, ch, promise));
+            negotiatorFactory.getSessionNegotiator(ch, promise));
     }
 }