X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-dom-spi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fcore%2Fspi%2Fdata%2FAbstractDOMStoreTreeChangePublisher.java;h=670cbe8d67da38a09a7db6f4d07a789f26996022;hp=d191fc397c787ff4120269f7fbdf8c54b24d19ff;hb=356ac60051791b56cd28390356906810c0db6024;hpb=dea515c8870769408b9bea29f555d6b71ff43211 diff --git a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/AbstractDOMStoreTreeChangePublisher.java b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/AbstractDOMStoreTreeChangePublisher.java index d191fc397c..670cbe8d67 100644 --- a/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/AbstractDOMStoreTreeChangePublisher.java +++ b/opendaylight/md-sal/sal-dom-spi/src/main/java/org/opendaylight/controller/sal/core/spi/data/AbstractDOMStoreTreeChangePublisher.java @@ -7,15 +7,14 @@ */ package org.opendaylight.controller.sal.core.spi.data; -import com.google.common.collect.ImmutableList; import java.util.Collection; import java.util.List; import javax.annotation.Nonnull; import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener; import org.opendaylight.controller.md.sal.dom.spi.AbstractDOMDataTreeChangeListenerRegistration; -import org.opendaylight.controller.md.sal.dom.spi.AbstractRegistrationTree; -import org.opendaylight.controller.md.sal.dom.spi.RegistrationTreeNode; -import org.opendaylight.controller.md.sal.dom.spi.RegistrationTreeSnapshot; +import org.opendaylight.mdsal.dom.spi.AbstractRegistrationTree; +import org.opendaylight.mdsal.dom.spi.RegistrationTreeNode; +import org.opendaylight.mdsal.dom.spi.RegistrationTreeSnapshot; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate; @@ -27,22 +26,26 @@ import org.slf4j.LoggerFactory; /** * Abstract base class for {@link DOMStoreTreeChangePublisher} implementations. */ -public abstract class AbstractDOMStoreTreeChangePublisher extends AbstractRegistrationTree> implements DOMStoreTreeChangePublisher { +public abstract class AbstractDOMStoreTreeChangePublisher + extends AbstractRegistrationTree> + implements DOMStoreTreeChangePublisher { private static final Logger LOG = LoggerFactory.getLogger(AbstractDOMStoreTreeChangePublisher.class); /** - * Callback for subclass to notify specified registrations of a candidate at a specified path. This method is guaranteed - * to be only called from within {@link #processCandidateTree(DataTreeCandidate)}. + * Callback for subclass to notify specified registrations of a candidate at a specified path. This method is + * guaranteed to be only called from within {@link #processCandidateTree(DataTreeCandidate)}. * * @param registrations Registrations which are affected by the candidate node * @param path Path of changed candidate node. Guaranteed to match the path specified by the registration * @param node Candidate node */ - protected abstract void notifyListeners(@Nonnull Collection> registrations, @Nonnull YangInstanceIdentifier path, @Nonnull DataTreeCandidateNode node); + protected abstract void notifyListeners(@Nonnull Collection> + registrations, @Nonnull YangInstanceIdentifier path, @Nonnull DataTreeCandidateNode node); /** * Callback notifying the subclass that the specified registration is being closed and it's user no longer - * wishes to receive notifications. This notification is invoked while the {@link org.opendaylight.yangtools.concepts.ListenerRegistration#close()} + * wishes to receive notifications. This notification is invoked while the + * {@link org.opendaylight.yangtools.concepts.ListenerRegistration#close()} * method is executing. Subclasses can use this callback to properly remove any delayed notifications pending * towards the registration. * @@ -62,24 +65,26 @@ public abstract class AbstractDOMStoreTreeChangePublisher extends AbstractRegist return; } - try (final RegistrationTreeSnapshot> snapshot = takeSnapshot()) { - final List toLookup = ImmutableList.copyOf(candidate.getRootPath().getPathArguments()); - lookupAndNotify(toLookup, 0, snapshot.getRootNode(), candidate); + try (RegistrationTreeSnapshot> snapshot = takeSnapshot()) { + lookupAndNotify(candidate.getRootPath().getPathArguments(), 0, snapshot.getRootNode(), candidate); } } @Override - public final AbstractDOMDataTreeChangeListenerRegistration registerTreeChangeListener(final YangInstanceIdentifier treeId, final L listener) { + public final AbstractDOMDataTreeChangeListenerRegistration + registerTreeChangeListener(final YangInstanceIdentifier treeId, final L listener) { // Take the write lock takeLock(); try { - final RegistrationTreeNode> node = findNodeFor(treeId.getPathArguments()); - final AbstractDOMDataTreeChangeListenerRegistration reg = new AbstractDOMDataTreeChangeListenerRegistration(listener) { - @Override - protected void removeRegistration() { - AbstractDOMStoreTreeChangePublisher.this.removeRegistration(node, this); - registrationRemoved(this); - } + final RegistrationTreeNode> node = + findNodeFor(treeId.getPathArguments()); + final AbstractDOMDataTreeChangeListenerRegistration reg = + new AbstractDOMDataTreeChangeListenerRegistration(listener) { + @Override + protected void removeRegistration() { + AbstractDOMStoreTreeChangePublisher.this.removeRegistration(node, this); + registrationRemoved(this); + } }; addRegistration(node, reg); @@ -90,16 +95,20 @@ public abstract class AbstractDOMStoreTreeChangePublisher extends AbstractRegist } } - private void lookupAndNotify(final List args, final int offset, final RegistrationTreeNode> node, final DataTreeCandidate candidate) { + private void lookupAndNotify(final List args, final int offset, + final RegistrationTreeNode> node, + final DataTreeCandidate candidate) { if (args.size() != offset) { final PathArgument arg = args.get(offset); - final RegistrationTreeNode> exactChild = node.getExactChild(arg); + final RegistrationTreeNode> exactChild = + node.getExactChild(arg); if (exactChild != null) { lookupAndNotify(args, offset + 1, exactChild, candidate); } - for (RegistrationTreeNode> c : node.getInexactChildren(arg)) { + for (RegistrationTreeNode> c : + node.getInexactChildren(arg)) { lookupAndNotify(args, offset + 1, c, candidate); } } else { @@ -107,7 +116,9 @@ public abstract class AbstractDOMStoreTreeChangePublisher extends AbstractRegist } } - private void notifyNode(final YangInstanceIdentifier path, final RegistrationTreeNode> regNode, final DataTreeCandidateNode candNode) { + private void notifyNode(final YangInstanceIdentifier path, + final RegistrationTreeNode> regNode, + final DataTreeCandidateNode candNode) { if (candNode.getModificationType() == ModificationType.UNMODIFIED) { LOG.debug("Skipping unmodified candidate {}", path); return; @@ -120,12 +131,14 @@ public abstract class AbstractDOMStoreTreeChangePublisher extends AbstractRegist for (DataTreeCandidateNode candChild : candNode.getChildNodes()) { if (candChild.getModificationType() != ModificationType.UNMODIFIED) { - final RegistrationTreeNode> regChild = regNode.getExactChild(candChild.getIdentifier()); + final RegistrationTreeNode> regChild = + regNode.getExactChild(candChild.getIdentifier()); if (regChild != null) { notifyNode(path.node(candChild.getIdentifier()), regChild, candChild); } - for (RegistrationTreeNode> rc : regNode.getInexactChildren(candChild.getIdentifier())) { + for (RegistrationTreeNode> rc : + regNode.getInexactChildren(candChild.getIdentifier())) { notifyNode(path.node(candChild.getIdentifier()), rc, candChild); } }