X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-dom-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fstore%2Fimpl%2Ftree%2FListenerRegistrationNode.java;h=e48438d6fa63aa1888fe8ab0df580ca7881d5650;hp=ee49effd31002e88c8f89924f7b41eb977f7b3e2;hb=08217531fbe76dbcc429c71d593894fc211e50aa;hpb=76b4cab3979151c4c599761301deab0766e0bbf1 diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/ListenerRegistrationNode.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/ListenerRegistrationNode.java index ee49effd31..e48438d6fa 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/ListenerRegistrationNode.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/ListenerRegistrationNode.java @@ -1,5 +1,6 @@ package org.opendaylight.controller.md.sal.dom.store.impl.tree; +import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -12,10 +13,14 @@ import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.google.common.base.Optional; -public class ListenerRegistrationNode implements StoreTreeNode,Identifiable { +public class ListenerRegistrationNode implements StoreTreeNode, Identifiable { + + private final Logger LOG = LoggerFactory.getLogger(ListenerRegistrationNode.class); private final ListenerRegistrationNode parent; private final Map children; @@ -23,10 +28,10 @@ public class ListenerRegistrationNode implements StoreTreeNode> listeners; private ListenerRegistrationNode(final PathArgument identifier) { - this(null,identifier); + this(null, identifier); } - private ListenerRegistrationNode(final ListenerRegistrationNode parent,final PathArgument identifier) { + private ListenerRegistrationNode(final ListenerRegistrationNode parent, final PathArgument identifier) { this.parent = parent; this.identifier = identifier; children = new HashMap<>(); @@ -42,23 +47,38 @@ public class ListenerRegistrationNode implements StoreTreeNode> getListeners() { - return listeners; + @SuppressWarnings({ "rawtypes", "unchecked" }) + public Collection> getListeners() { + return (Collection) listeners; } @Override public synchronized Optional getChild(final PathArgument child) { + return Optional.fromNullable(children.get(child)); + } + + public synchronized ListenerRegistrationNode ensureChild(final PathArgument child) { ListenerRegistrationNode potential = (children.get(child)); - if(potential == null) { + if (potential == null) { potential = new ListenerRegistrationNode(this, child); children.put(child, potential); } - return Optional.of(potential); + return potential; } - public >> ListenerRegistration registerDataChangeListener( + /** + * + * Registers listener on this node. + * + * @param path Full path on which listener is registered. + * @param listener Listener + * @param scope Scope of triggering event. + * @return + */ + public >> ListenerRegistration registerDataChangeListener(final InstanceIdentifier path, final L listener, final DataChangeScope scope) { - DataChangeListenerRegistration listenerReg = new DataChangeListenerRegistration(listener, scope,this); + + DataChangeListenerRegistration listenerReg = new DataChangeListenerRegistration(path,listener, scope, this); listeners.add(listenerReg); return listenerReg; } @@ -68,9 +88,8 @@ public class ListenerRegistrationNode implements StoreTreeNode>> extends AbstractObjectRegistration - implements ListenerRegistration { + public static class DataChangeListenerRegistration>> + extends AbstractObjectRegistration implements + org.opendaylight.controller.md.sal.dom.store.impl.DataChangeListenerRegistration { private final DataChangeScope scope; private ListenerRegistrationNode node; + private final InstanceIdentifier path; - public DataChangeListenerRegistration(final T listener, final DataChangeScope scope, final ListenerRegistrationNode node) { + public DataChangeListenerRegistration(final InstanceIdentifier path,final T listener, final DataChangeScope scope, + final ListenerRegistrationNode node) { super(listener); - + this.path = path; this.scope = scope; this.node = node; } - protected DataChangeScope getScope() { + @Override + public DataChangeScope getScope() { return scope; } @@ -117,5 +137,10 @@ public class ListenerRegistrationNode implements StoreTreeNode