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;
10 import org.opendaylight.controller.config.util.capability.Capability;
11 import org.opendaylight.controller.sal.common.util.NoopAutoCloseable;
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.netconf.monitoring.GetSchema;
20 import java.util.Collections;
23 public class MdsalMonitoringMapperFactory implements NetconfOperationServiceFactory, AutoCloseable {
25 private final NetconfOperationService operationService;
26 private final MonitoringToMdsalWriter monitoringToMdsalWriter;
27 private final NetconfOperationServiceFactoryListener netconfOperationServiceFactoryListener;
29 private static final Set<Capability> CAPABILITIES = Collections.emptySet();
31 public MdsalMonitoringMapperFactory(final NetconfOperationServiceFactoryListener netconfOperationServiceFactoryListener,
32 final NetconfMonitoringService netconfMonitoringService,
33 final MonitoringToMdsalWriter monitoringToMdsalWriter) {
35 this.netconfOperationServiceFactoryListener = netconfOperationServiceFactoryListener;
36 this.monitoringToMdsalWriter = monitoringToMdsalWriter;
38 this.operationService = new NetconfOperationService() {
40 public Set<NetconfOperation> getNetconfOperations() {
41 return Collections.singleton(new GetSchema(netconfMonitoringService));
50 this.netconfOperationServiceFactoryListener.onAddNetconfOperationServiceFactory(this);
54 public NetconfOperationService createService(final String netconfSessionIdForReporting) {
55 return operationService;
59 public Set<Capability> getCapabilities() {
61 // No capabilities exposed to prevent clashes with schemas from mdsal-netconf-connector (it exposes all the schemas)
62 // If the schemas exposed by mdsal-netconf-connector are filtered, this class would expose monitoring related models
67 public AutoCloseable registerCapabilityListener(final CapabilityListener listener) {
68 return NoopAutoCloseable.INSTANCE;
72 * Invoke using blueprint
76 monitoringToMdsalWriter.close();
77 netconfOperationServiceFactoryListener.onRemoveNetconfOperationServiceFactory(this);