Generate notifications when policies change
[policy/pap.git] / main / src / main / java / org / onap / policy / pap / main / comm / PdpRequests.java
index 5863b2c..4e1e923 100644 (file)
@@ -23,6 +23,7 @@ package org.onap.policy.pap.main.comm;
 import lombok.Getter;
 import org.onap.policy.models.pdp.concepts.PdpMessage;
 import org.onap.policy.pap.main.comm.msgdata.Request;
+import org.onap.policy.pap.main.notification.PolicyNotifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -44,6 +45,12 @@ public class PdpRequests {
     @Getter
     private final String pdpName;
 
+    /**
+     * Notifier for policy update completions.
+     */
+    @Getter
+    private final PolicyNotifier notifier;
+
     /**
      * Index of request currently being published.
      */
@@ -60,8 +67,9 @@ public class PdpRequests {
      *
      * @param pdpName name of the PDP with which the requests are associated
      */
-    public PdpRequests(String pdpName) {
+    public PdpRequests(String pdpName, PolicyNotifier notifier) {
         this.pdpName = pdpName;
+        this.notifier = notifier;
     }
 
     /**
@@ -71,6 +79,8 @@ public class PdpRequests {
      */
     public void addSingleton(Request request) {
 
+        request.setNotifier(notifier);
+
         if (request.getMessage().getName() == null) {
             throw new IllegalArgumentException("unexpected broadcast for " + pdpName);
         }
@@ -86,7 +96,7 @@ public class PdpRequests {
         singletons[priority] = request;
 
         // stop publishing anything of a lower priority
-        QueueToken<PdpMessage> token = stopPublishingLowerPriority(priority);
+        final QueueToken<PdpMessage> token = stopPublishingLowerPriority(priority);
 
         // start publishing if nothing of higher priority
         if (higherPrioritySingleton(priority)) {