Mark netconf related factory as functional interface
- deprecate/remove redundant factory implementations
Change-Id: I29ba9f3397c37c02b37d07dff16a4203186c5fcd
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/DefaultNetconfDevice.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/DefaultNetconfDevice.java
index f700768..c952027 100644
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/DefaultNetconfDevice.java
+++ b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/DefaultNetconfDevice.java
@@ -49,7 +49,7 @@
public DefaultNetconfDevice(NetconfDeviceInfo deviceInfo)
throws NetconfException {
netconfDeviceInfo = deviceInfo;
- sessionFactory = new NetconfSessionMinaImpl.MinaSshNetconfSessionFactory();
+ sessionFactory = (ncDevInfo) -> new NetconfSessionMinaImpl(ncDevInfo);
try {
netconfSession = sessionFactory.createNetconfSession(deviceInfo);
} catch (NetconfException e) {
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfControllerImpl.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfControllerImpl.java
index ab0189d..e0959cd 100644
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfControllerImpl.java
+++ b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfControllerImpl.java
@@ -118,7 +118,7 @@
private final NetconfDeviceOutputEventListener downListener = new DeviceDownEventListener();
protected Set<NetconfDeviceListener> netconfDeviceListeners = new CopyOnWriteArraySet<>();
- protected NetconfDeviceFactory deviceFactory = new DefaultNetconfDeviceFactory();
+ protected NetconfDeviceFactory deviceFactory = (deviceInfo) -> new DefaultNetconfDevice(deviceInfo);
protected final ExecutorService executor =
Executors.newCachedThreadPool(groupedThreads("onos/netconfdevicecontroller",
@@ -343,14 +343,17 @@
}
- //Device factory for the specific NetconfDeviceImpl
+ /**
+ * Device factory for the specific NetconfDeviceImpl.
+ *
+ * @deprecated in 1.14.0
+ */
+ @Deprecated
private class DefaultNetconfDeviceFactory implements NetconfDeviceFactory {
@Override
public NetconfDevice createNetconfDevice(NetconfDeviceInfo netconfDeviceInfo)
throws NetconfException {
- log.info("Creating NETCONF session to {} with {}",
- netconfDeviceInfo.getDeviceId(), NetconfSshClientLib.APACHE_MINA);
return new DefaultNetconfDevice(netconfDeviceInfo);
}
}
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfSessionMinaImpl.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfSessionMinaImpl.java
index 31ec0ac..846ec26 100644
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfSessionMinaImpl.java
+++ b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfSessionMinaImpl.java
@@ -199,6 +199,9 @@
}
private void startClient() throws IOException {
+ log.info("Creating NETCONF session to {}",
+ deviceInfo.getDeviceId());
+
client = SshClient.setUpDefaultClient();
client.getProperties().putIfAbsent(FactoryManager.IDLE_TIMEOUT,
TimeUnit.SECONDS.toMillis(idleTimeout));
@@ -1019,6 +1022,10 @@
}
}
+ /**
+ * @deprecated in 1.14.0
+ */
+ @Deprecated
public static class MinaSshNetconfSessionFactory implements NetconfSessionFactory {
@Override