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.config.yang.netconf.mdsal.monitoring;
11 import org.opendaylight.netconf.api.capability.Capability;
12 import org.opendaylight.netconf.api.monitoring.CapabilityListener;
13 import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
14 import org.opendaylight.netconf.mapping.api.NetconfOperation;
15 import org.opendaylight.netconf.mapping.api.NetconfOperationService;
16 import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
17 import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactoryListener;
18 import org.opendaylight.yangtools.concepts.Registration;
20 public final class MdsalMonitoringMapperFactory implements NetconfOperationServiceFactory, AutoCloseable {
21 private final MonitoringToMdsalWriter monitoringToMdsalWriter;
22 private final NetconfOperationServiceFactoryListener netconfOperationServiceFactoryListener;
23 private final NetconfMonitoringService netconfMonitoringService;
25 public MdsalMonitoringMapperFactory(
26 final NetconfOperationServiceFactoryListener netconfOperationServiceFactoryListener,
27 final NetconfMonitoringService netconfMonitoringService,
28 final MonitoringToMdsalWriter monitoringToMdsalWriter) {
30 this.netconfOperationServiceFactoryListener = netconfOperationServiceFactoryListener;
31 this.netconfMonitoringService = netconfMonitoringService;
32 this.monitoringToMdsalWriter = monitoringToMdsalWriter;
33 this.netconfOperationServiceFactoryListener.onAddNetconfOperationServiceFactory(this);
37 public NetconfOperationService createService(final String netconfSessionIdForReporting) {
38 return new NetconfOperationService() {
40 public Set<NetconfOperation> getNetconfOperations() {
41 return Set.of(new GetSchema(netconfSessionIdForReporting, netconfMonitoringService));
52 public Set<Capability> getCapabilities() {
53 // TODO No capabilities exposed to prevent clashes with schemas from mdsal-netconf-connector (it exposes all the
54 // schemas). If the schemas exposed by mdsal-netconf-connector are filtered, this class would expose monitoring
60 public Registration registerCapabilityListener(final CapabilityListener listener) {
65 * Invoked using blueprint.
69 monitoringToMdsalWriter.close();
70 netconfOperationServiceFactoryListener.onRemoveNetconfOperationServiceFactory(this);