BUG-338 Allow incomming BGP connections.
[bgpcep.git] / bgp / testtool / src / main / java / org / opendaylight / protocol / bgp / testtool / TestingListener.java
index a61cce23f82e8561f8044aa307bc38a443634e6a..587c4a48d0f9c07ab15cf885c033c598b460e85e 100644 (file)
@@ -7,46 +7,42 @@
  */
 package org.opendaylight.protocol.bgp.testtool;
 
-import org.opendaylight.protocol.bgp.parser.BGPMessage;
 import org.opendaylight.protocol.bgp.parser.BGPSession;
-import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
 import org.opendaylight.protocol.bgp.parser.BGPTerminationReason;
-import org.opendaylight.protocol.framework.DispatcherImpl;
+import org.opendaylight.protocol.bgp.rib.impl.spi.ReusableBGPPeer;
+import org.opendaylight.yangtools.yang.binding.Notification;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
  * Testing BGP Listener.
  */
-public class TestingListener implements BGPSessionListener {
-       private static final Logger logger = LoggerFactory.getLogger(TestingListener.class);
-
-       DispatcherImpl d;
-
-       TestingListener(final DispatcherImpl d) {
-               this.d = d;
-       }
-
-       @Override
-       public void onMessage(final BGPSession session, final BGPMessage message) {
-               logger.info("Client Listener: message received: {}", message.toString());
-       }
-
-       @Override
-       public void onSessionUp(final BGPSession session) {
-               logger.info("Client Listener: Session Up.");
-       }
-
-       @Override
-       public void onSessionDown(final BGPSession session, final Exception e) {
-               logger.info("Client Listener: Connection lost.");
-               session.close();
-               // this.d.stop();
-       }
-
-       @Override
-       public void onSessionTerminated(final BGPSession session, final BGPTerminationReason cause) {
-               logger.info("Client Listener: Connection lost: {}.", cause);
-               // this.d.stop();
-       }
+public class TestingListener implements ReusableBGPPeer {
+    private static final Logger LOG = LoggerFactory.getLogger(TestingListener.class);
+
+    @Override
+    public void onMessage(final BGPSession session, final Notification message) {
+        LOG.info("Client Listener: message received: {}", message.toString());
+    }
+
+    @Override
+    public void onSessionUp(final BGPSession session) {
+        LOG.info("Client Listener: Session Up.");
+    }
+
+    @Override
+    public void onSessionDown(final BGPSession session, final Exception e) {
+        LOG.info("Client Listener: Connection lost.");
+        session.close();
+    }
+
+    @Override
+    public void onSessionTerminated(final BGPSession session, final BGPTerminationReason cause) {
+        LOG.info("Client Listener: Connection lost: {}.", cause);
+    }
+
+    @Override
+    public void releaseConnection() {
+        LOG.info("Client Listener: Connection released.");
+    }
 }