2 * Copyright (c) 2020 Pantheon Technologies s.r.o. 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
9 package org.opendaylight.netconf.mdsal.notification.impl;
11 import java.util.Collection;
12 import org.opendaylight.mdsal.binding.api.DataBroker;
13 import org.opendaylight.mdsal.binding.api.DataObjectModification;
14 import org.opendaylight.mdsal.binding.api.DataTreeModification;
15 import org.opendaylight.netconf.notifications.NetconfNotificationCollector;
16 import org.opendaylight.netconf.notifications.YangLibraryPublisherRegistration;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.ModulesState;
18 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.YangLibraryChange;
19 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.YangLibraryChangeBuilder;
20 import org.opendaylight.yangtools.concepts.ListenerRegistration;
21 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
24 * Listens on the set of modules and submodules changes in data store and publishes
25 * to base netconf notification stream listener a server-specific identifier representing
26 * the current set of modules and submodules.
28 * @deprecated ietf-yang-library:yang-library-change was deprecated in the new RFC8525.
29 * Use {@link YangLibraryNotificationProducerRFC8525}.
31 @Deprecated(forRemoval = true)
32 public final class YangLibraryNotificationProducer extends OperationalDatastoreListener<ModulesState>
33 implements AutoCloseable {
35 private static final InstanceIdentifier<ModulesState> MODULES_STATE_INSTANCE_IDENTIFIER =
36 InstanceIdentifier.create(ModulesState.class);
38 private final ListenerRegistration<?> yangLibraryChangeListenerRegistration;
39 private final YangLibraryPublisherRegistration yangLibraryPublisherRegistration;
41 public YangLibraryNotificationProducer(final NetconfNotificationCollector netconfNotificationCollector,
42 final DataBroker dataBroker) {
43 super(MODULES_STATE_INSTANCE_IDENTIFIER);
44 this.yangLibraryPublisherRegistration = netconfNotificationCollector.registerYangLibraryPublisher();
45 this.yangLibraryChangeListenerRegistration = registerOnChanges(dataBroker);
49 public void onDataTreeChanged(final Collection<DataTreeModification<ModulesState>> changes) {
50 for (DataTreeModification<ModulesState> change : changes) {
51 final DataObjectModification<ModulesState> rootNode = change.getRootNode();
52 final ModulesState dataAfter = rootNode.getDataAfter();
53 if (dataAfter != null) {
54 final YangLibraryChange yangLibraryChange = new YangLibraryChangeBuilder()
55 .setModuleSetId(dataAfter.getModuleSetId())
57 yangLibraryPublisherRegistration.onYangLibraryChange(yangLibraryChange);
63 * Invoked by blueprint.
67 if (yangLibraryPublisherRegistration != null) {
68 yangLibraryPublisherRegistration.close();
70 if (yangLibraryChangeListenerRegistration != null) {
71 yangLibraryChangeListenerRegistration.close();