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;
19 public final class MdsalMonitoringMapperFactory implements NetconfOperationServiceFactory, AutoCloseable {
20 private final MonitoringToMdsalWriter monitoringToMdsalWriter;
21 private final NetconfOperationServiceFactoryListener netconfOperationServiceFactoryListener;
22 private final NetconfMonitoringService netconfMonitoringService;
24 public MdsalMonitoringMapperFactory(
25 final NetconfOperationServiceFactoryListener netconfOperationServiceFactoryListener,
26 final NetconfMonitoringService netconfMonitoringService,
27 final MonitoringToMdsalWriter monitoringToMdsalWriter) {
29 this.netconfOperationServiceFactoryListener = netconfOperationServiceFactoryListener;
30 this.netconfMonitoringService = netconfMonitoringService;
31 this.monitoringToMdsalWriter = monitoringToMdsalWriter;
32 this.netconfOperationServiceFactoryListener.onAddNetconfOperationServiceFactory(this);
36 public NetconfOperationService createService(final String netconfSessionIdForReporting) {
37 return new NetconfOperationService() {
39 public Set<NetconfOperation> getNetconfOperations() {
40 return Set.of(new GetSchema(netconfSessionIdForReporting, netconfMonitoringService));
51 public Set<Capability> getCapabilities() {
52 // TODO No capabilities exposed to prevent clashes with schemas from mdsal-netconf-connector (it exposes all the
53 // schemas). If the schemas exposed by mdsal-netconf-connector are filtered, this class would expose monitoring
59 public AutoCloseable registerCapabilityListener(final CapabilityListener listener) {
64 * Invoked using blueprint.
68 monitoringToMdsalWriter.close();
69 netconfOperationServiceFactoryListener.onRemoveNetconfOperationServiceFactory(this);