Bug 625 - Fixed Apache DM Activation after removing xtend code. 85/7485/1
authorVaclav Demcak <vdemcak@cisco.com>
Thu, 29 May 2014 09:44:19 +0000 (11:44 +0200)
committerTony Tkacik <ttkacik@cisco.com>
Thu, 29 May 2014 09:44:19 +0000 (11:44 +0200)
Apache DM does not provide any compile time/ runtime checks
for callbacks missing / modified.
Previously in xtend callbacks were provided by @Property
annotation, which generated setters and getters for this.

In refactor these was accidentally ommited. From code-perspective
it was not obvious that this affects Apache DM instantiation of
this service, since Apache DM uses strings and reflection.

Change-Id: I655ce7c1bc9971e3db370c5048057c1e6070a46d
Signed-off-by: Vaclav Demcak <vdemcak@cisco.com>
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/ComponentActivator.java
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/DataPacketAdapter.java
opendaylight/md-sal/compatibility/sal-compatibility/src/main/java/org/opendaylight/controller/sal/compatibility/topology/TopologyAdapter.java

index b3a89a4..ba68d52 100644 (file)
@@ -107,6 +107,7 @@ public class ComponentActivator extends ComponentActivatorAbstractBase {
                 nodeConnectorFactory,
                 topology,
                 tpProvider,
+                this // Used for setBroker callback
         };
     }
 
index f95f978..4d26a3a 100644 (file)
@@ -17,13 +17,19 @@ import org.slf4j.LoggerFactory;
 
 class DataPacketAdapter implements PacketProcessingListener {
     private static final Logger LOG = LoggerFactory.getLogger(DataPacketAdapter.class);
+
+    // These are injected via Apache DM (see ComponentActivator)
     private IPluginOutDataPacketService dataPacketPublisher;
 
     @Override
     public void onPacketReceived(final PacketReceived packet) {
         try {
             RawPacket inPacket = toRawPacket(packet);
-            dataPacketPublisher.receiveDataPacket(inPacket);
+            if (dataPacketPublisher != null) {
+                dataPacketPublisher.receiveDataPacket(inPacket);
+            } else {
+                LOG.warn("IPluginOutDataPacketService is not available. Not forwarding packet to AD-SAL.");
+            }
         } catch (ConstructionException e) {
             LOG.warn("Failed to construct raw packet from {}, dropping it", packet, e);
         }
@@ -34,4 +40,13 @@ class DataPacketAdapter implements PacketProcessingListener {
         ret.setIncomingNodeConnector(NodeMapping.toADNodeConnector(received.getIngress()));
         return ret;
     }
+
+    public IPluginOutDataPacketService getDataPacketPublisher() {
+        return dataPacketPublisher;
+    }
+
+    // These are injected via Apache DM (see ComponentActivator)
+    public void setDataPacketPublisher(final IPluginOutDataPacketService dataPacketPublisher) {
+        this.dataPacketPublisher = dataPacketPublisher;
+    }
 }
index b609add..4e3cf69 100644 (file)
@@ -23,8 +23,10 @@ public class TopologyAdapter implements IPluginInTopologyService {
     private final InstanceIdentifier<Topology> topology = InstanceIdentifier.builder(NetworkTopology.class)
             .child(Topology.class, new TopologyKey(new TopologyId("flow:1"))).toInstance();
 
-    // FIXME: seems to be unused
+    // Injected via Apache DM
     private IPluginOutTopologyService topologyPublisher;
+
+
     private DataProviderService dataService;
 
     public void setDataService(final DataProviderService dataService) {
@@ -37,4 +39,12 @@ public class TopologyAdapter implements IPluginInTopologyService {
         final Topology t = reader.readOperationalData(topology);
         topologyPublisher.edgeUpdate(TopologyMapping.toADEdgeUpdates(t, reader));
     }
+
+    public IPluginOutTopologyService getTopologyPublisher() {
+        return topologyPublisher;
+    }
+
+    public void setTopologyPublisher(final IPluginOutTopologyService topologyPublisher) {
+        this.topologyPublisher = topologyPublisher;
+    }
 }