Split out NetconfMapperAggregator 99/104299/6
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 7 Feb 2023 18:47:51 +0000 (19:47 +0100)
committerRobert Varga <nite@hq.sk>
Wed, 8 Feb 2023 15:15:05 +0000 (15:15 +0000)
Create a component to host the corresponding Blueprint element.
This starts the path to making the contract of
AggregatedNetconfOperationServiceFactory more explicit.

JIRA: NETCONF-951
Change-Id: Ic4f0164ac3423f39ca0d52a6200dcbbfa8f35f7f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
netconf/mdsal-netconf-impl/src/main/java/org/opendaylight/netconf/impl/mdsal/NetconfMapperAggregator.java [new file with mode: 0644]
netconf/mdsal-netconf-impl/src/main/resources/OSGI-INF/blueprint/mdsal-netconf-impl.xml
protocol/netconf-impl/src/main/java/org/opendaylight/netconf/impl/osgi/AggregatedNetconfOperationServiceFactory.java

diff --git a/netconf/mdsal-netconf-impl/src/main/java/org/opendaylight/netconf/impl/mdsal/NetconfMapperAggregator.java b/netconf/mdsal-netconf-impl/src/main/java/org/opendaylight/netconf/impl/mdsal/NetconfMapperAggregator.java
new file mode 100644 (file)
index 0000000..44c624f
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.netconf.impl.mdsal;
+
+import org.opendaylight.netconf.impl.osgi.AggregatedNetconfOperationServiceFactory;
+import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory;
+import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactoryListener;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+
+@Component(service = { NetconfOperationServiceFactory.class, NetconfOperationServiceFactoryListener.class },
+           property = "type=mapper-aggregator-registry", immediate = true)
+public final class NetconfMapperAggregator extends AggregatedNetconfOperationServiceFactory {
+    @Activate
+    public NetconfMapperAggregator() {
+        super();
+    }
+
+    @Override
+    @Deactivate
+    public void close() {
+        super.close();
+    }
+}
index f766af9d7ba2ef6b6bd9d342288b88daede62b48..8ea1f5fec3a1018a047a98ccdb4a400a7f696d0f 100644 (file)
@@ -28,6 +28,9 @@
                odl:type="global-netconf-ssh-scheduled-executor"/>
     <reference id="sessionIdProvider"
                interface="org.opendaylight.netconf.impl.SessionIdProvider"/>
+    <reference id="aggregatedNetconfOperationServiceFactory"
+               interface="org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory"
+               odl:type="mapper-aggregator-registry"/>
 
     <cm:property-placeholder persistent-id="org.opendaylight.netconf.impl" update-strategy="none">
         <cm:default-properties>
         </cm:default-properties>
     </cm:property-placeholder>
 
-    <!--NetconfMapperAggregator -->
-
-    <bean id="aggregatedNetconfOperationServiceFactory"
-          class="org.opendaylight.netconf.impl.osgi.AggregatedNetconfOperationServiceFactory"
-          destroy-method="close">
-    </bean>
-    <service ref="aggregatedNetconfOperationServiceFactory"
-             interface="org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactoryListener"
-             odl:type="mapper-aggregator-registry">
-    </service>
-
     <!--NetconfServerDispatcher -->
 
     <bean id="aggregatedNetconfOperationServiceFactoryMappers"
index d1dc45124a71bcfa5745214faea9200a24cea03a..30083fb4bc85fb772a43d8d31ae0a1542f77f3f1 100644 (file)
@@ -30,7 +30,10 @@ import org.opendaylight.yangtools.concepts.Registration;
 /**
  * NetconfOperationService aggregator. Makes a collection of operation services accessible as one.
  */
-public final class AggregatedNetconfOperationServiceFactory
+// Non-final for OSGi DS
+// FIXME: split into abstract class for the multiple uses we have, which really is about which construct is being
+//        invoked
+public class AggregatedNetconfOperationServiceFactory
         implements NetconfOperationServiceFactory, NetconfOperationServiceFactoryListener, AutoCloseable {
     private final Set<NetconfOperationServiceFactory> factories = ConcurrentHashMap.newKeySet();
     private final Multimap<NetconfOperationServiceFactory, Registration> registrations =
@@ -45,7 +48,7 @@ public final class AggregatedNetconfOperationServiceFactory
     }
 
     @Override
-    public synchronized void onAddNetconfOperationServiceFactory(final NetconfOperationServiceFactory service) {
+    public final synchronized void onAddNetconfOperationServiceFactory(final NetconfOperationServiceFactory service) {
         factories.add(service);
 
         for (final CapabilityListener listener : listeners) {
@@ -54,13 +57,14 @@ public final class AggregatedNetconfOperationServiceFactory
     }
 
     @Override
-    public synchronized void onRemoveNetconfOperationServiceFactory(final NetconfOperationServiceFactory service) {
+    public final synchronized void onRemoveNetconfOperationServiceFactory(
+            final NetconfOperationServiceFactory service) {
         factories.remove(service);
         registrations.removeAll(service).forEach(Registration::close);
     }
 
     @Override
-    public Set<Capability> getCapabilities() {
+    public final Set<Capability> getCapabilities() {
         final Set<Capability> capabilities = new HashSet<>();
         for (final NetconfOperationServiceFactory factory : factories) {
             capabilities.addAll(factory.getCapabilities());
@@ -69,7 +73,7 @@ public final class AggregatedNetconfOperationServiceFactory
     }
 
     @Override
-    public synchronized Registration registerCapabilityListener(final CapabilityListener listener) {
+    public final synchronized Registration registerCapabilityListener(final CapabilityListener listener) {
         final Map<NetconfOperationServiceFactory, Registration> regs = new HashMap<>();
 
         for (final NetconfOperationServiceFactory factory : factories) {
@@ -93,7 +97,7 @@ public final class AggregatedNetconfOperationServiceFactory
     }
 
     @Override
-    public synchronized NetconfOperationService createService(final String netconfSessionIdForReporting) {
+    public final synchronized NetconfOperationService createService(final String netconfSessionIdForReporting) {
         return new AggregatedNetconfOperation(factories, netconfSessionIdForReporting);
     }