ONOS-6381 Transactional event listeners

Change-Id: I8f279d78323dea467796e8d37e3117a407af9f76
diff --git a/core/api/src/main/java/org/onosproject/store/service/AsyncDocumentTree.java b/core/api/src/main/java/org/onosproject/store/service/AsyncDocumentTree.java
index 1f0902c..46dcdd5 100644
--- a/core/api/src/main/java/org/onosproject/store/service/AsyncDocumentTree.java
+++ b/core/api/src/main/java/org/onosproject/store/service/AsyncDocumentTree.java
@@ -16,6 +16,8 @@
 
 package org.onosproject.store.service;
 
+import org.onosproject.store.primitives.NodeUpdate;
+
 import java.util.Map;
 import java.util.concurrent.CompletableFuture;
 
@@ -29,7 +31,7 @@
  * @param <V> document tree value type
  */
 @NotThreadSafe
-public interface AsyncDocumentTree<V> extends DistributedPrimitive {
+public interface AsyncDocumentTree<V> extends DistributedPrimitive, Transactional<NodeUpdate<V>> {
 
     @Override
     default Type primitiveType() {
diff --git a/core/api/src/main/java/org/onosproject/store/service/DocumentTreeEvent.java b/core/api/src/main/java/org/onosproject/store/service/DocumentTreeEvent.java
index f640da8..81b28ac 100644
--- a/core/api/src/main/java/org/onosproject/store/service/DocumentTreeEvent.java
+++ b/core/api/src/main/java/org/onosproject/store/service/DocumentTreeEvent.java
@@ -44,7 +44,9 @@
         /**
          * Signifies an existing node being deleted.
          */
-        DELETED
+        DELETED,
+        TRANSACTION_START,
+        TRANSACTION_END
     }
 
     private final DocumentPath path;
@@ -77,6 +79,22 @@
         this.newValue = newValue;
         this.oldValue = oldValue;
     }
+    /**
+     * Constructs a new {@code DocumentTreeEvent}.
+     *
+     * @param path path to the node
+     * @param newValue optional new value; will be empty if node was deleted
+     * @param oldValue optional old value; will be empty if node was created
+     */
+    public DocumentTreeEvent(DocumentPath path,
+                             Optional<Versioned<V>> newValue,
+                             Optional<Versioned<V>> oldValue) {
+        this.path = path;
+        this.newValue = newValue;
+        this.oldValue = oldValue;
+        this.type = newValue != null ?
+                oldValue != null ? Type.UPDATED : Type.CREATED : Type.DELETED;
+    }
 
     /**
      * Returns the path to the changed node.