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
8 package org.opendaylight.netconf.mdsal.notification.impl;
10 import java.util.Collection;
11 import org.opendaylight.mdsal.binding.api.DataBroker;
12 import org.opendaylight.mdsal.binding.api.DataTreeModification;
13 import org.opendaylight.netconf.notifications.NetconfNotificationCollector;
14 import org.opendaylight.netconf.notifications.YangLibraryPublisherRegistration;
15 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.ModulesState;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.YangLibraryChangeBuilder;
17 import org.opendaylight.yangtools.concepts.ListenerRegistration;
18 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
19 import org.osgi.service.component.annotations.Activate;
20 import org.osgi.service.component.annotations.Component;
21 import org.osgi.service.component.annotations.Deactivate;
22 import org.osgi.service.component.annotations.Reference;
25 * Listens on the set of modules and submodules changes in data store and publishes
26 * to base netconf notification stream listener a server-specific identifier representing
27 * the current set of modules and submodules.
29 * @deprecated ietf-yang-library:yang-library-change was deprecated in the new RFC8525.
30 * Use {@link YangLibraryNotificationProducerRFC8525}.
32 @Component(service = { })
33 @Deprecated(forRemoval = true)
34 public final class YangLibraryNotificationProducer extends OperationalDatastoreListener<ModulesState>
35 implements AutoCloseable {
36 private static final InstanceIdentifier<ModulesState> MODULES_STATE_INSTANCE_IDENTIFIER =
37 InstanceIdentifier.create(ModulesState.class);
39 private final ListenerRegistration<?> yangLibraryChangeListenerRegistration;
40 private final YangLibraryPublisherRegistration yangLibraryPublisherRegistration;
43 public YangLibraryNotificationProducer(
44 @Reference(target = "(type=netconf-notification-manager)") final NetconfNotificationCollector notifManager,
45 @Reference final DataBroker dataBroker) {
46 super(MODULES_STATE_INSTANCE_IDENTIFIER);
47 yangLibraryPublisherRegistration = notifManager.registerYangLibraryPublisher();
48 yangLibraryChangeListenerRegistration = registerOnChanges(dataBroker);
54 if (yangLibraryPublisherRegistration != null) {
55 yangLibraryPublisherRegistration.close();
57 if (yangLibraryChangeListenerRegistration != null) {
58 yangLibraryChangeListenerRegistration.close();
63 public void onDataTreeChanged(final Collection<DataTreeModification<ModulesState>> changes) {
64 for (DataTreeModification<ModulesState> change : changes) {
65 final ModulesState dataAfter = change.getRootNode().getDataAfter();
66 if (dataAfter != null) {
67 yangLibraryPublisherRegistration.onYangLibraryChange(new YangLibraryChangeBuilder()
68 .setModuleSetId(dataAfter.getModuleSetId())