Make LoggingRemoteDevice a singleton
[netconf.git] / netconf / tools / netconf-testtool / src / main / java / org / opendaylight / netconf / test / tool / client / stress / StressClient.java
index a9d0d38a4f4faa3cc7f9bccfe3b3a3dea6e27cf3..33dd64183952c47a6f5c348b294002d0ab796e70 100644 (file)
@@ -42,6 +42,24 @@ import org.xml.sax.SAXException;
 public final class StressClient {
     private static final Logger LOG = LoggerFactory.getLogger(StressClient.class);
 
+    static final RemoteDevice<NetconfDeviceCommunicator> LOGGING_REMOTE_DEVICE = new RemoteDevice<>() {
+        @Override
+        public void onRemoteSessionUp(final NetconfSessionPreferences remoteSessionCapabilities,
+                final NetconfDeviceCommunicator netconfDeviceCommunicator) {
+            LOG.info("Session established");
+        }
+
+        @Override
+        public void onRemoteSessionDown() {
+            LOG.info("Session down");
+        }
+
+        @Override
+        public void onNotification(final NetconfMessage notification) {
+            LOG.info("Notification received: {}", notification);
+        }
+    };
+
     static final QName COMMIT_QNAME = QName.create(CommitInput.QNAME, "commit");
     public static final NetconfMessage COMMIT_MSG = new NetconfMessage(readString("""
         <rpc message-id="commit-batch" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
@@ -227,22 +245,4 @@ public final class StressClient {
         return params.legacyFraming ? ConfigurableClientDispatcher.createLegacy(nioGroup, nioGroup, timer)
             : ConfigurableClientDispatcher.createChunked(nioGroup, nioGroup, timer);
     }
-
-    static class LoggingRemoteDevice implements RemoteDevice<NetconfDeviceCommunicator> {
-        @Override
-        public void onRemoteSessionUp(final NetconfSessionPreferences remoteSessionCapabilities,
-                                      final NetconfDeviceCommunicator netconfDeviceCommunicator) {
-            LOG.info("Session established");
-        }
-
-        @Override
-        public void onRemoteSessionDown() {
-            LOG.info("Session down");
-        }
-
-        @Override
-        public void onNotification(final NetconfMessage notification) {
-            LOG.info("Notification received: {}", notification);
-        }
-    }
 }