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.netconf.northbound.monitoring;
10 import static java.util.Objects.requireNonNull;
13 import org.opendaylight.netconf.api.capability.Capability;
14 import org.opendaylight.netconf.server.api.monitoring.CapabilityListener;
15 import org.opendaylight.netconf.server.api.monitoring.NetconfMonitoringService;
16 import org.opendaylight.netconf.server.api.operations.NetconfOperation;
17 import org.opendaylight.netconf.server.api.operations.NetconfOperationService;
18 import org.opendaylight.netconf.server.api.operations.NetconfOperationServiceFactory;
19 import org.opendaylight.netconf.server.api.operations.NetconfOperationServiceFactoryListener;
20 import org.opendaylight.netconf.server.mdsal.monitoring.GetSchema;
21 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.SessionIdType;
22 import org.opendaylight.yangtools.concepts.Registration;
23 import org.osgi.service.component.annotations.Activate;
24 import org.osgi.service.component.annotations.Component;
25 import org.osgi.service.component.annotations.Deactivate;
26 import org.osgi.service.component.annotations.Reference;
28 @Component(service = { })
29 public final class MdsalMonitoringMapperFactory implements NetconfOperationServiceFactory, AutoCloseable {
30 private final NetconfOperationServiceFactoryListener netconfOperationServiceFactoryListener;
31 private final NetconfMonitoringService netconfMonitoringService;
34 public MdsalMonitoringMapperFactory(
35 @Reference(target = "(type=mapper-aggregator-registry)")
36 final NetconfOperationServiceFactoryListener netconfOperationServiceFactoryListener,
37 @Reference(target = "(type=netconf-server-monitoring)")
38 final NetconfMonitoringService netconfMonitoringService) {
39 this.netconfOperationServiceFactoryListener = requireNonNull(netconfOperationServiceFactoryListener);
40 this.netconfMonitoringService = requireNonNull(netconfMonitoringService);
41 this.netconfOperationServiceFactoryListener.onAddNetconfOperationServiceFactory(this);
47 netconfOperationServiceFactoryListener.onRemoveNetconfOperationServiceFactory(this);
51 public NetconfOperationService createService(final SessionIdType sessionId) {
52 return new NetconfOperationService() {
54 public Set<NetconfOperation> getNetconfOperations() {
55 return Set.of(new GetSchema(sessionId, netconfMonitoringService));
66 public Set<Capability> getCapabilities() {
67 // TODO No capabilities exposed to prevent clashes with schemas from mdsal-netconf-connector (it exposes all the
68 // schemas). If the schemas exposed by mdsal-netconf-connector are filtered, this class would expose monitoring
74 public Registration registerCapabilityListener(final CapabilityListener listener) {