2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.cluster.datastore;
10 import java.util.Collection;
11 import javax.annotation.concurrent.NotThreadSafe;
12 import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
13 import org.opendaylight.mdsal.dom.spi.AbstractDOMDataTreeChangeListenerRegistration;
14 import org.opendaylight.mdsal.dom.spi.store.AbstractDOMStoreTreeChangePublisher;
15 import org.opendaylight.yangtools.concepts.ListenerRegistration;
16 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
17 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
22 * Default implementation of ShardDataTreeChangeListenerPublisher that directly generates and publishes
23 * notifications for DataTreeChangeListeners.
25 * @author Thomas Pantelis
28 final class DefaultShardDataTreeChangeListenerPublisher extends AbstractDOMStoreTreeChangePublisher
29 implements ShardDataTreeChangeListenerPublisher {
30 private static final Logger LOG = LoggerFactory.getLogger(DefaultShardDataTreeChangeListenerPublisher.class);
33 public void publishChanges(final DataTreeCandidate candidate, String logContext) {
34 processCandidateTree(candidate);
38 public ShardDataTreeChangeListenerPublisher newInstance() {
39 return new DefaultShardDataTreeChangeListenerPublisher();
43 protected void notifyListener(AbstractDOMDataTreeChangeListenerRegistration<?> registration,
44 Collection<DataTreeCandidate> changes) {
45 registration.getInstance().onDataTreeChanged(changes);
49 protected void registrationRemoved(final AbstractDOMDataTreeChangeListenerRegistration<?> registration) {
50 LOG.debug("Registration {} removed", registration);
54 public <L extends org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener> ListenerRegistration<L>
55 registerTreeChangeListener(final YangInstanceIdentifier treeId, final L listener) {
56 final AbstractDOMDataTreeChangeListenerRegistration<DOMDataTreeChangeListener> registration =
57 super.registerTreeChangeListener(treeId, (org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener)
58 changes -> listener.onDataTreeChanged(changes));
60 return new org.opendaylight.controller.md.sal.dom.spi.AbstractDOMDataTreeChangeListenerRegistration<L>(
63 protected void removeRegistration() {