Merge "sal-restconf-broker initial implementation needs https://git.opendaylight...
[controller.git] / opendaylight / netconf / netconf-client / src / main / java / org / opendaylight / controller / netconf / client / NetconfClientSessionNegotiatorFactory.java
index abfbdd526c5f7bb6796c7c0273060e7b91aa8933..e678a601ff46a5496fbc311047a2162afa5bde61 100644 (file)
@@ -26,15 +26,16 @@ import org.xml.sax.SAXException;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 
-public class NetconfClientSessionNegotiatorFactory implements SessionNegotiatorFactory {
-
-    private final Timer timer;
+public class NetconfClientSessionNegotiatorFactory implements SessionNegotiatorFactory<NetconfMessage, NetconfClientSession, NetconfClientSessionListener> {
 
     private final Optional<String> additionalHeader;
+    private final long connectionTimeoutMillis;
+    private final Timer timer;
 
-    public NetconfClientSessionNegotiatorFactory(Timer timer, Optional<String> additionalHeader) {
-        this.timer = timer;
+    public NetconfClientSessionNegotiatorFactory(Timer timer, Optional<String> additionalHeader, long connectionTimeoutMillis) {
+        this.timer = Preconditions.checkNotNull(timer);
         this.additionalHeader = additionalHeader;
+        this.connectionTimeoutMillis = connectionTimeoutMillis;
     }
 
     private static NetconfMessage loadHelloMessageTemplate() {
@@ -48,8 +49,8 @@ public class NetconfClientSessionNegotiatorFactory implements SessionNegotiatorF
     }
 
     @Override
-    public SessionNegotiator getSessionNegotiator(SessionListenerFactory sessionListenerFactory, Channel channel,
-            Promise promise) {
+    public SessionNegotiator<NetconfClientSession> getSessionNegotiator(SessionListenerFactory<NetconfClientSessionListener> sessionListenerFactory, Channel channel,
+            Promise<NetconfClientSession> promise) {
         // Hello message needs to be recreated every time
         NetconfMessage helloMessage = loadHelloMessageTemplate();
         if(this.additionalHeader.isPresent()) {
@@ -57,7 +58,6 @@ public class NetconfClientSessionNegotiatorFactory implements SessionNegotiatorF
         }
         NetconfSessionPreferences proposal = new NetconfSessionPreferences(helloMessage);
         return new NetconfClientSessionNegotiator(proposal, promise, channel, timer,
-                sessionListenerFactory.getSessionListener());
+                sessionListenerFactory.getSessionListener(), connectionTimeoutMillis);
     }
-
 }