Integrate mdsal-netconf-monitoring
[netconf.git] / plugins / netconf-server-mdsal / src / main / java / org / opendaylight / netconf / server / mdsal / notifications / NetconfNotificationOperationServiceFactory.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.netconf.server.mdsal.notifications;
9
10 import static java.util.Objects.requireNonNull;
11
12 import java.util.Set;
13 import org.opendaylight.netconf.api.capability.Capability;
14 import org.opendaylight.netconf.server.api.monitoring.CapabilityListener;
15 import org.opendaylight.netconf.server.api.notifications.NetconfNotificationRegistry;
16 import org.opendaylight.netconf.server.api.operations.NetconfOperationService;
17 import org.opendaylight.netconf.server.api.operations.NetconfOperationServiceFactory;
18 import org.opendaylight.netconf.server.api.operations.NetconfOperationServiceFactoryListener;
19 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.SessionIdType;
20 import org.opendaylight.yangtools.concepts.Registration;
21 import org.osgi.service.component.annotations.Activate;
22 import org.osgi.service.component.annotations.Component;
23 import org.osgi.service.component.annotations.Deactivate;
24 import org.osgi.service.component.annotations.Reference;
25
26 @Component(service = NetconfOperationServiceFactory.class, immediate = true,
27            property = "type=mdsal-netconf-notification")
28 public final class NetconfNotificationOperationServiceFactory implements NetconfOperationServiceFactory, AutoCloseable {
29     private final NetconfNotificationRegistry notifManager;
30     private final NetconfOperationServiceFactoryListener aggregatorRegistry;
31
32     @Activate
33     public NetconfNotificationOperationServiceFactory(
34             @Reference(target = "(type=netconf-notification-manager)") final NetconfNotificationRegistry notifManager,
35             @Reference(target = "(type=mapper-aggregator-registry)")
36             final NetconfOperationServiceFactoryListener aggregatorRegistry) {
37         this.notifManager = requireNonNull(notifManager);
38         this.aggregatorRegistry = requireNonNull(aggregatorRegistry);
39         this.aggregatorRegistry.onAddNetconfOperationServiceFactory(this);
40     }
41
42     @Deactivate
43     @Override
44     public void close() {
45         aggregatorRegistry.onRemoveNetconfOperationServiceFactory(this);
46     }
47
48     @Override
49     public Set<Capability> getCapabilities() {
50         // TODO
51         // No capabilities exposed to prevent clashes with schemas from
52         // config-netconf-connector (it exposes all the schemas)
53         // If the schemas exposed by config-netconf-connector are filtered,
54         // this class would expose monitoring related models
55         return Set.of();
56     }
57
58     @Override
59     public NetconfOperationService createService(final SessionIdType sessionId) {
60         return new NetconfNotificationOperationService(sessionId, notifManager);
61     }
62
63     @Override
64     public Registration registerCapabilityListener(final CapabilityListener listener) {
65         return () -> { };
66     }
67 }