From 79e3715414de90d717b86c2eaff3d849fbf0a130 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Thu, 9 Feb 2023 16:43:52 +0100 Subject: [PATCH] Convert MappingUtilsImpl into a Component This is as simple a component as they come: a single dependency and a single service published. Split it out of the blueprint container. Change-Id: Ib94603ca9e7f54639444cde9c1cba30967d3b23b Signed-off-by: Robert Varga --- common/pom.xml | 4 ++++ .../common/mapping/MappingUtilsImpl.java | 18 +++++++++++------- .../OSGI-INF/blueprint/common-blueprint.xml | 7 +------ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/common/pom.xml b/common/pom.xml index 7b9031a58..5bb0e995d 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -156,6 +156,10 @@ com.google.code.gson gson + + org.osgi + org.osgi.service.component.annotations + diff --git a/common/src/main/java/org/opendaylight/transportpce/common/mapping/MappingUtilsImpl.java b/common/src/main/java/org/opendaylight/transportpce/common/mapping/MappingUtilsImpl.java index c94e26caa..63d904db4 100644 --- a/common/src/main/java/org/opendaylight/transportpce/common/mapping/MappingUtilsImpl.java +++ b/common/src/main/java/org/opendaylight/transportpce/common/mapping/MappingUtilsImpl.java @@ -7,6 +7,8 @@ */ package org.opendaylight.transportpce.common.mapping; +import static java.util.Objects.requireNonNull; + import com.google.common.collect.ImmutableMap; import java.util.ArrayList; import java.util.List; @@ -33,16 +35,17 @@ import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.IfOC import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.IfOtsiOtsigroup; import org.opendaylight.yang.gen.v1.http.org.openroadm.port.types.rev201211.SupportedIfCapability; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - -public class MappingUtilsImpl implements MappingUtils { +@Component +public final class MappingUtilsImpl implements MappingUtils { private static final Logger LOG = LoggerFactory.getLogger(MappingUtilsImpl.class); - private final DataBroker dataBroker; - private static final ImmutableMap CAP_TYPE_MAP = ImmutableMap.builder() .put("If400GE{qname=(http://org/openroadm/port/types?revision=2020-03-27)if-400GE}", If400GE.VALUE) @@ -67,10 +70,11 @@ public class MappingUtilsImpl implements MappingUtils { If100GEODU4.VALUE) .build(); - public MappingUtilsImpl(DataBroker dataBroker) { - - this.dataBroker = dataBroker; + private final DataBroker dataBroker; + @Activate + public MappingUtilsImpl(@Reference DataBroker dataBroker) { + this.dataBroker = requireNonNull(dataBroker); } public String getOpenRoadmVersion(String nodeId) { diff --git a/common/src/main/resources/OSGI-INF/blueprint/common-blueprint.xml b/common/src/main/resources/OSGI-INF/blueprint/common-blueprint.xml index 527ef648c..62688f344 100644 --- a/common/src/main/resources/OSGI-INF/blueprint/common-blueprint.xml +++ b/common/src/main/resources/OSGI-INF/blueprint/common-blueprint.xml @@ -11,6 +11,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html + @@ -18,10 +19,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html - - - - @@ -106,6 +103,4 @@ and is available at http://www.eclipse.org/legal/epl-v10.html - - -- 2.36.6