From c8ef39052ea5e77cbce6d27657a2a17e401277a3 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Tue, 7 Feb 2023 19:47:51 +0100 Subject: [PATCH] Split out NetconfMapperAggregator 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 --- .../impl/mdsal/NetconfMapperAggregator.java | 30 +++++++++++++++++++ .../OSGI-INF/blueprint/mdsal-netconf-impl.xml | 14 ++------- ...regatedNetconfOperationServiceFactory.java | 16 ++++++---- 3 files changed, 43 insertions(+), 17 deletions(-) create mode 100644 netconf/mdsal-netconf-impl/src/main/java/org/opendaylight/netconf/impl/mdsal/NetconfMapperAggregator.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 index 0000000000..44c624fdd9 --- /dev/null +++ b/netconf/mdsal-netconf-impl/src/main/java/org/opendaylight/netconf/impl/mdsal/NetconfMapperAggregator.java @@ -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(); + } +} diff --git a/netconf/mdsal-netconf-impl/src/main/resources/OSGI-INF/blueprint/mdsal-netconf-impl.xml b/netconf/mdsal-netconf-impl/src/main/resources/OSGI-INF/blueprint/mdsal-netconf-impl.xml index f766af9d7b..8ea1f5fec3 100644 --- a/netconf/mdsal-netconf-impl/src/main/resources/OSGI-INF/blueprint/mdsal-netconf-impl.xml +++ b/netconf/mdsal-netconf-impl/src/main/resources/OSGI-INF/blueprint/mdsal-netconf-impl.xml @@ -28,6 +28,9 @@ odl:type="global-netconf-ssh-scheduled-executor"/> + @@ -36,17 +39,6 @@ - - - - - - - factories = ConcurrentHashMap.newKeySet(); private final Multimap 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 getCapabilities() { + public final Set getCapabilities() { final Set 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 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); } -- 2.36.6