Convert OlmPowerServiceImpl into a Component 37/104937/4
authorGilles Thouenon <gilles.thouenon@orange.com>
Mon, 13 Mar 2023 16:25:58 +0000 (17:25 +0100)
committerguillaume.lambert <guillaume.lambert@orange.com>
Sun, 26 Mar 2023 20:57:44 +0000 (22:57 +0200)
JIRA: TRNSPRTPCE-736
Signed-off-by: Gilles Thouenon <gilles.thouenon@orange.com>
Change-Id: I5a77219ea44649cb151ae333c7c49e99ab005c31

olm/src/main/java/org/opendaylight/transportpce/olm/service/OlmPowerServiceImpl.java
olm/src/main/resources/OSGI-INF/blueprint/olm-blueprint.xml
olm/src/test/java/org/opendaylight/transportpce/olm/service/OlmPowerServiceImplTest.java

index 606bdbe04ba10984bb8724a88806ddb938c379a7..2419fd96ea8dab1069985a7cd228473bc7fcac30 100644 (file)
@@ -92,9 +92,13 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.top
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.Decimal64;
+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;
 
+@Component
 public class OlmPowerServiceImpl implements OlmPowerService {
     private static final Logger LOG = LoggerFactory.getLogger(OlmPowerServiceImpl.class);
     private final MappingUtils mappingUtils;
@@ -104,26 +108,22 @@ public class OlmPowerServiceImpl implements OlmPowerService {
     private final DeviceTransactionManager deviceTransactionManager;
     private final PortMapping portMapping;
 
-    public OlmPowerServiceImpl(DataBroker dataBroker, PowerMgmt powerMgmt,
-                               DeviceTransactionManager deviceTransactionManager, PortMapping portMapping,
-                               MappingUtils mappingUtils, OpenRoadmInterfaces openRoadmInterfaces) {
+    @Activate
+    public OlmPowerServiceImpl(@Reference DataBroker dataBroker,
+            @Reference PowerMgmt powerMgmt,
+            @Reference DeviceTransactionManager deviceTransactionManager,
+            @Reference PortMapping portMapping,
+            @Reference MappingUtils mappingUtils,
+            @Reference OpenRoadmInterfaces openRoadmInterfaces) {
         this.dataBroker = dataBroker;
         this.powerMgmt = powerMgmt;
         this.portMapping = portMapping;
         this.deviceTransactionManager = deviceTransactionManager;
         this.mappingUtils = mappingUtils;
         this.openRoadmInterfaces = openRoadmInterfaces;
+        LOG.debug("OlmPowerServiceImpl Instantiated");
     }
 
-    public void init() {
-        LOG.info("init ...");
-    }
-
-    public void close() {
-        LOG.info("close ...");
-    }
-
-
     @Override
     public GetPmOutput getPm(GetPmInput pmInput) {
         GetPmOutputBuilder pmOutputBuilder = new GetPmOutputBuilder();
index 986cbf56d9a2217931251f361b6ea93d6c220849..f85f4cb6340a385d0c5fec4c5292106a360285c1 100644 (file)
@@ -8,22 +8,8 @@ terms of the Eclipse Public License v1.0 which accompanies this distribution,
 and is available at http://www.eclipse.org/legal/epl-v10.html
 -->
 <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-  <reference id="dataBroker" interface="org.opendaylight.mdsal.binding.api.DataBroker"/>
   <reference id="rpcProviderService" interface="org.opendaylight.mdsal.binding.api.RpcProviderService" />
-  <reference id="openRoadmInterfaces" interface="org.opendaylight.transportpce.common.openroadminterfaces.OpenRoadmInterfaces" />
-  <reference id="deviceTransactionManager" interface="org.opendaylight.transportpce.common.device.DeviceTransactionManager" />
-  <reference id="portMapping" interface="org.opendaylight.transportpce.common.mapping.PortMapping" />
-  <reference id="mappingUtils" interface="org.opendaylight.transportpce.common.mapping.MappingUtils" />
-  <reference id="powerMgmt" interface="org.opendaylight.transportpce.olm.power.PowerMgmt" />
-
-  <bean id="olmPowerServiceImpl" class="org.opendaylight.transportpce.olm.service.OlmPowerServiceImpl">
-    <argument ref="dataBroker" />
-    <argument ref="powerMgmt" />
-    <argument ref="deviceTransactionManager" />
-    <argument ref="portMapping" />
-    <argument ref="mappingUtils" />
-    <argument ref="openRoadmInterfaces" />
-  </bean>
+  <reference id="olmPowerServiceImpl" interface="org.opendaylight.transportpce.olm.service.OlmPowerService" />
 
   <bean id="olmPowerServiceRpcImpl" class="org.opendaylight.transportpce.olm.OlmPowerServiceRpcImpl">
     <argument ref="olmPowerServiceImpl" />
index 86113ab5f72ecc181a49db136034e33182a48320..513987fe43ec0d46c40f5adb2d7bf8c4907ae42f 100644 (file)
@@ -62,13 +62,6 @@ public class OlmPowerServiceImplTest  extends AbstractTest {
                 this.portMapping, this.mappingUtils, this.openRoadmInterfaces);
     }
 
-    @Test
-    void dummyTest() {
-        OlmPowerServiceImpl olmPowerServiceImpl = (OlmPowerServiceImpl) this.olmPowerService;
-        olmPowerServiceImpl.init();
-        olmPowerServiceImpl.close();
-    }
-
     @Test
     void testGetPm() {
         when(this.mappingUtils.getOpenRoadmVersion(anyString()))