Remove FactoryManagerConfigurator 20/107920/2
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 20 Sep 2023 00:05:56 +0000 (02:05 +0200)
committerRobert Varga <nite@hq.sk>
Wed, 20 Sep 2023 14:50:58 +0000 (14:50 +0000)
This record is really just a simple lambda within its sole user.

JIRA: NETCONF-1106
Change-Id: I8a743b80a57a5f5dffa265276878cba7b1673cdc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
protocol/netconf-server/src/main/java/org/opendaylight/netconf/server/NetconfServerFactoryImpl.java

index c58f0560d10034517f6e09e1d466f4005f504c89..a27c260100ac06fb99411b7bcf66fa8213285228 100644 (file)
@@ -19,7 +19,6 @@ import java.util.List;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.netconf.server.api.NetconfServerFactory;
-import org.opendaylight.netconf.shaded.sshd.server.ServerFactoryManager;
 import org.opendaylight.netconf.shaded.sshd.server.SshServer;
 import org.opendaylight.netconf.transport.api.TransportChannel;
 import org.opendaylight.netconf.transport.api.TransportChannelListener;
@@ -73,10 +72,18 @@ public final class NetconfServerFactoryImpl implements NetconfServerFactory {
 
     @Override
     public ListenableFuture<SSHServer> createSshServer(final TcpServerGrouping tcpParams,
-        final SshServerGrouping sshParams, final ServerFactoryManagerConfigurator configurator)
-            throws UnsupportedConfigurationException {
-        return SSHServer.listen(EMPTY_LISTENER, createBootstrap(), tcpParams, sshParams,
-            new FactoryManagerConfigurator(channelInitializer, configurator));
+            final SshServerGrouping sshParams, final ServerFactoryManagerConfigurator configurator)
+                throws UnsupportedConfigurationException {
+        final var initializer = requireNonNull(channelInitializer);
+
+        return SSHServer.listen(EMPTY_LISTENER, createBootstrap(), tcpParams, sshParams, factoryManager -> {
+            if (configurator != null) {
+                configurator.configureServerFactoryManager(factoryManager);
+            }
+            if (factoryManager instanceof SshServer server) {
+                server.setSubsystemFactories(List.of(new NetconfSubsystemFactory(initializer)));
+            }
+        });
     }
 
     private record ChannelInitializerListener(
@@ -95,23 +102,4 @@ public final class NetconfServerFactoryImpl implements NetconfServerFactory {
             LOG.error("Transport channel failed", cause);
         }
     }
-
-    private record FactoryManagerConfigurator(
-            @NonNull ServerChannelInitializer channelInitializer,
-            @Nullable ServerFactoryManagerConfigurator configurator) implements ServerFactoryManagerConfigurator {
-        FactoryManagerConfigurator {
-            requireNonNull(channelInitializer);
-        }
-
-        @Override
-        public void configureServerFactoryManager(final ServerFactoryManager factoryManager)
-                throws UnsupportedConfigurationException {
-            if (configurator != null) {
-                configurator.configureServerFactoryManager(factoryManager);
-            }
-            if (factoryManager instanceof SshServer server) {
-                server.setSubsystemFactories(List.of(new NetconfSubsystemFactory(channelInitializer)));
-            }
-        }
-    }
 }