Convert mdsal-netconf-notification to OSGi DS
[netconf.git] / netconf / mdsal-netconf-notification / src / main / java / org / opendaylight / netconf / mdsal / notification / impl / 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.mdsal.notification.impl;
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.api.monitoring.CapabilityListener;
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.notifications.NetconfNotificationRegistry;
19 import org.opendaylight.yangtools.concepts.Registration;
20 import org.osgi.service.component.annotations.Activate;
21 import org.osgi.service.component.annotations.Component;
22 import org.osgi.service.component.annotations.Deactivate;
23 import org.osgi.service.component.annotations.Reference;
24
25 @Component(service = NetconfOperationServiceFactory.class, immediate = true,
26            property = "type=mdsal-netconf-notification")
27 public final class NetconfNotificationOperationServiceFactory implements NetconfOperationServiceFactory, AutoCloseable {
28     private final NetconfNotificationRegistry notifManager;
29     private final NetconfOperationServiceFactoryListener aggregatorRegistry;
30
31     @Activate
32     public NetconfNotificationOperationServiceFactory(
33             @Reference(target = "(type=netconf-notification-manager)") final NetconfNotificationRegistry notifManager,
34             @Reference(target = "(type=mapper-aggregator-registry)")
35             final NetconfOperationServiceFactoryListener aggregatorRegistry) {
36         this.notifManager = requireNonNull(notifManager);
37         this.aggregatorRegistry = requireNonNull(aggregatorRegistry);
38         this.aggregatorRegistry.onAddNetconfOperationServiceFactory(this);
39     }
40
41     @Deactivate
42     @Override
43     public void close() {
44         aggregatorRegistry.onRemoveNetconfOperationServiceFactory(this);
45     }
46
47     @Override
48     public Set<Capability> getCapabilities() {
49         // TODO
50         // No capabilities exposed to prevent clashes with schemas from
51         // config-netconf-connector (it exposes all the schemas)
52         // If the schemas exposed by config-netconf-connector are filtered,
53         // this class would expose monitoring related models
54         return Set.of();
55     }
56
57     @Override
58     public NetconfOperationService createService(final String netconfSessionIdForReporting) {
59         return new NetconfNotificationOperationService(netconfSessionIdForReporting, notifManager);
60     }
61
62     @Override
63     public Registration registerCapabilityListener(final CapabilityListener listener) {
64         return () -> { };
65     }
66 }