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.server.mdsal.notifications;
10 import org.opendaylight.mdsal.binding.api.DataBroker;
11 import org.opendaylight.mdsal.binding.api.DataListener;
12 import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
13 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
14 import org.opendaylight.netconf.server.api.notifications.NetconfNotificationCollector;
15 import org.opendaylight.netconf.server.api.notifications.YangLibraryPublisherRegistration;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.ModulesState;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.YangLibraryChangeBuilder;
18 import org.opendaylight.yangtools.concepts.Registration;
19 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
20 import org.osgi.service.component.annotations.Activate;
21 import org.osgi.service.component.annotations.Component;
22 import org.osgi.service.component.annotations.Deactivate;
23 import org.osgi.service.component.annotations.Reference;
26 * Listens on the set of modules and submodules changes in data store and publishes to base NETCONF notification stream
27 * listener a server-specific identifier representing 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 implements DataListener<ModulesState>, AutoCloseable {
35 private final Registration yangLibraryChangeListenerRegistration;
36 private final YangLibraryPublisherRegistration yangLibraryPublisherRegistration;
39 public YangLibraryNotificationProducer(
40 @Reference(target = "(type=netconf-notification-manager)") final NetconfNotificationCollector notifManager,
41 @Reference final DataBroker dataBroker) {
42 yangLibraryPublisherRegistration = notifManager.registerYangLibraryPublisher();
43 yangLibraryChangeListenerRegistration = dataBroker.registerDataListener(
44 DataTreeIdentifier.of(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(ModulesState.class)),
51 if (yangLibraryPublisherRegistration != null) {
52 yangLibraryPublisherRegistration.close();
54 if (yangLibraryChangeListenerRegistration != null) {
55 yangLibraryChangeListenerRegistration.close();
60 public void dataChangedTo(final ModulesState data) {
62 yangLibraryPublisherRegistration.onYangLibraryChange(new YangLibraryChangeBuilder()
63 .setModuleSetId(data.getModuleSetId())