Reuse NetconfClientBuilder in NetconfCallHomeServer
[netconf.git] / netconf / callhome-protocol / src / main / java / org / opendaylight / netconf / callhome / protocol / NetconfCallHomeServerBuilder.java
index c915ade8a33a44ab5334ef9502690c634a9b6366..136adf351a6c388ed855679e8b4fe22f81ab40f9 100644 (file)
@@ -13,15 +13,14 @@ import io.netty.util.HashedWheelTimer;
 import java.net.InetSocketAddress;
 import java.util.Optional;
 import java.util.concurrent.TimeUnit;
-import org.apache.sshd.client.SshClient;
-import org.opendaylight.netconf.callhome.protocol.CallHomeSessionContext.Factory;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.netconf.client.NetconfClientSessionNegotiatorFactory;
-import org.opendaylight.yangtools.concepts.Builder;
-
-public class NetconfCallHomeServerBuilder implements Builder<NetconfCallHomeServer> {
+import org.opendaylight.netconf.nettyutil.handler.ssh.client.NetconfClientBuilder;
+import org.opendaylight.netconf.shaded.sshd.client.SshClient;
 
+public class NetconfCallHomeServerBuilder {
     private static final long DEFAULT_SESSION_TIMEOUT_MILLIS = TimeUnit.SECONDS.toMillis(5);
-    private static final int DEFAULT_CALL_HOME_PORT = 6666;
+    private static final int DEFAULT_CALL_HOME_PORT = 4334;
 
     private SshClient sshClient;
     private EventLoopGroup nettyGroup;
@@ -39,11 +38,10 @@ public class NetconfCallHomeServerBuilder implements Builder<NetconfCallHomeServ
         this.recorder = recorder;
     }
 
-    @Override
-    public NetconfCallHomeServer build() {
-        Factory factory =
-                new CallHomeSessionContext.Factory(nettyGroup(), negotiatorFactory(), subsystemListener());
-        return new NetconfCallHomeServer(sshClient(), authProvider(), factory, bindAddress(), this.recorder);
+    public @NonNull NetconfCallHomeServer build() {
+        return new NetconfCallHomeServer(sshClient(), authProvider(),
+            new CallHomeSessionContext.Factory(nettyGroup(), negotiatorFactory(), subsystemListener()),
+            bindAddress(), recorder);
     }
 
     public SshClient getSshClient() {
@@ -107,7 +105,7 @@ public class NetconfCallHomeServerBuilder implements Builder<NetconfCallHomeServ
     }
 
     private static SshClient defaultSshClient() {
-        return SshClient.setUpDefaultClient();
+        return new NetconfClientBuilder().build();
     }
 
     private static NetconfClientSessionNegotiatorFactory defaultNegotiationFactory() {