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.YangLibrary;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev190104.YangLibraryUpdateBuilder;
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 modules, submodules, datastores, and datastore schemas changes in data store and publishes to base
27 * NETCONF notification stream listener a server-specific identifier representing the current set of modules,
28 * submodules, datastores, and datastore schemas.
30 @Component(service = { })
31 public final class YangLibraryNotificationProducerRFC8525
32 implements DataListener<YangLibrary>, AutoCloseable {
33 private final Registration yangLibraryChangeListenerRegistration;
34 private final YangLibraryPublisherRegistration yangLibraryPublisherRegistration;
37 public YangLibraryNotificationProducerRFC8525(
38 @Reference(target = "(type=netconf-notification-manager)") final NetconfNotificationCollector notifManager,
39 @Reference final DataBroker dataBroker) {
40 yangLibraryPublisherRegistration = notifManager.registerYangLibraryPublisher();
41 yangLibraryChangeListenerRegistration = dataBroker.registerDataListener(
42 DataTreeIdentifier.of(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(YangLibrary.class)),
49 if (yangLibraryPublisherRegistration != null) {
50 yangLibraryPublisherRegistration.close();
52 if (yangLibraryChangeListenerRegistration != null) {
53 yangLibraryChangeListenerRegistration.close();
58 public void dataChangedTo(final YangLibrary data) {
60 yangLibraryPublisherRegistration.onYangLibraryUpdate(new YangLibraryUpdateBuilder()
61 .setContentId(data.getContentId())