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>
--- /dev/null
+/*
+ * 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();
+ }
+}
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"
/**
* 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 =
}
@Override
- public synchronized void onAddNetconfOperationServiceFactory(final NetconfOperationServiceFactory service) {
+ public final synchronized void onAddNetconfOperationServiceFactory(final NetconfOperationServiceFactory service) {
factories.add(service);
for (final CapabilityListener listener : listeners) {
}
@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());
}
@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) {
}
@Override
- public synchronized NetconfOperationService createService(final String netconfSessionIdForReporting) {
+ public final synchronized NetconfOperationService createService(final String netconfSessionIdForReporting) {
return new AggregatedNetconfOperation(factories, netconfSessionIdForReporting);
}