device context provides attached any messege type listener
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / device / DeviceContextImpl.java
index eaca19ccd9d11a98fefaafeff26a1d67a9956a44..c797107668ad8da38124507f27e8861a17cad4c8 100644 (file)
@@ -33,6 +33,7 @@ import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
 import org.opendaylight.openflowplugin.api.openflow.device.TranslatorLibrary;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.api.openflow.device.exception.DeviceDataException;
+import org.opendaylight.openflowplugin.api.openflow.device.listener.AnyMessageTypeListener;
 import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;
 import org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey;
 import org.opendaylight.openflowplugin.impl.translator.PacketReceivedTranslator;
@@ -72,6 +73,7 @@ public class DeviceContextImpl implements DeviceContext {
     private final Map<SwitchConnectionDistinguisher, ConnectionContext> auxiliaryConnectionContexts;
     private final TransactionChainManager txChainManager;
     private TranslatorLibrary translatorLibrary;
+    private AnyMessageTypeListener anyMessageTypeListener;
 
     @VisibleForTesting
     DeviceContextImpl(@Nonnull final ConnectionContext primaryConnectionContext,
@@ -166,6 +168,17 @@ public class DeviceContextImpl implements DeviceContext {
         requests.put(xid.getValue(), requestFutureContext);
     }
 
+    @Override
+    public void attachAnyMessageTypeListener(final AnyMessageTypeListener anyMessageTypeListener) {
+        this.anyMessageTypeListener = anyMessageTypeListener;
+        primaryConnectionContext.getConnectionAdapter().setMessageListener(anyMessageTypeListener);
+    }
+
+    @Override
+    public AnyMessageTypeListener getAnyMessageTypeListener() {
+        return this.anyMessageTypeListener;
+    }
+
     @Override
     public void processReply(final OfHeader ofHeader) {
         final RequestContext requestContext = getRequests().get(ofHeader.getXid());