Migrate test-provider to OSGi DS 67/100067/7
authorSangwook Ha <sangwook.ha@verizon.com>
Thu, 17 Mar 2022 08:13:14 +0000 (01:13 -0700)
committerSangwook Ha <sangwook.ha@verizon.com>
Thu, 17 Mar 2022 09:07:53 +0000 (02:07 -0700)
This is a very simple component, just migrate it over.

Change-Id: I455184dea3c1df406bad8e85e23886f86a4b3595
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Signed-off-by: Sangwook Ha <sangwook.ha@verizon.com>
test-provider/pom.xml
test-provider/src/main/java/org/opendaylight/openflowplugin/test/OpenflowpluginTestActivator.java

index 9c77939e9bb5b25cd4c6e51d7a7225fbbda6a151..3007e4b6ab742666e804b1d978c651aad2af9ecc 100644 (file)
@@ -39,6 +39,7 @@
             <artifactId>model-flow-statistics</artifactId>
         </dependency>
         <dependency>
+            <!-- FIXME: Migrate to Karaf commands instead -->
             <groupId>org.eclipse.tycho</groupId>
             <artifactId>org.eclipse.osgi</artifactId>
             <version>3.10.101.v20150820-1432</version>
@@ -54,9 +55,8 @@
             <optional>true</optional>
         </dependency>
         <dependency>
-            <groupId>org.apache.aries.blueprint</groupId>
-            <artifactId>blueprint-maven-plugin-annotation</artifactId>
-            <optional>true</optional>
+            <groupId>org.osgi</groupId>
+            <artifactId>osgi.cmpn</artifactId>
         </dependency>
     </dependencies>
 
                 <artifactId>maven-bundle-plugin</artifactId>
                 <extensions>true</extensions>
             </plugin>
-            <plugin>
-                <groupId>org.apache.aries.blueprint</groupId>
-                <artifactId>blueprint-maven-plugin</artifactId>
-            </plugin>
         </plugins>
     </build>
 </project>
index a7aeb6482f6de9c6180be275cb0703f9e96dab62..f15679bade401b182c75113fb8ddc92b945da5ea 100644 (file)
@@ -7,24 +7,22 @@
  */
 package org.opendaylight.openflowplugin.test;
 
-import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
+import javax.inject.Inject;
 import javax.inject.Singleton;
-import org.apache.aries.blueprint.annotation.service.Reference;
 import org.opendaylight.mdsal.binding.api.DataBroker;
 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
 import org.opendaylight.mdsal.binding.api.NotificationService;
 import org.opendaylight.mdsal.binding.api.RpcProviderService;
 import org.osgi.framework.BundleContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Reference;
 
 @Singleton
+@Component(service = { })
 public class OpenflowpluginTestActivator implements AutoCloseable {
-    private static final Logger LOG = LoggerFactory
-            .getLogger(OpenflowpluginTestActivator.class);
-
-    private RpcProviderService rpcRegistry;
     private final OpenflowpluginTestServiceProvider provider;
     private final OpenflowpluginGroupTestServiceProvider groupProvider = new OpenflowpluginGroupTestServiceProvider();
     private final OpenflowpluginMeterTestServiceProvider meterProvider = new OpenflowpluginMeterTestServiceProvider();
@@ -51,67 +49,44 @@ public class OpenflowpluginTestActivator implements AutoCloseable {
 
     public static final String NODE_ID = "foo:node:1";
 
+    @Activate
+    @Inject
     public OpenflowpluginTestActivator(@Reference DataBroker dataBroker,
+            @Reference RpcProviderService rpcRegistry,
             @Reference NotificationService notificationService,
             @Reference NotificationPublishService notificationPublishService, BundleContext ctx) {
         provider = new OpenflowpluginTestServiceProvider(dataBroker, notificationPublishService);
-        OpenflowpluginTestCommandProvider openflowpluginTestCommandProvider = new OpenflowpluginTestCommandProvider(
-                dataBroker, notificationService, ctx);
-        this.cmdProvider = openflowpluginTestCommandProvider;
-        OpenflowpluginGroupTestCommandProvider openflowpluginGroupTestCommandProvider =
-                new OpenflowpluginGroupTestCommandProvider(dataBroker, ctx);
-        this.cmdGroupProvider = openflowpluginGroupTestCommandProvider;
-        OpenflowpluginMeterTestCommandProvider openflowpluginMeterTestCommandProvider =
-                new OpenflowpluginMeterTestCommandProvider(dataBroker, ctx);
-        this.cmdMeterProvider = openflowpluginMeterTestCommandProvider;
-        OpenflowpluginTableFeaturesTestCommandProvider openflowpluginTableFeaturesTestCommandProvider =
-                new OpenflowpluginTableFeaturesTestCommandProvider(dataBroker, ctx);
-        this.cmdTableProvider = openflowpluginTableFeaturesTestCommandProvider;
-        OpenflowpluginStatsTestCommandProvider openflowpluginStatsTestCommandProvider =
-                new OpenflowpluginStatsTestCommandProvider(dataBroker, ctx);
-        this.cmdStatsProvider = openflowpluginStatsTestCommandProvider;
-        OpenflowpluginTestNodeConnectorNotification openflowpluginTestNodeConnectorNotification =
-                new OpenflowpluginTestNodeConnectorNotification(notificationService);
-        this.cmdNodeConnectorNotification = openflowpluginTestNodeConnectorNotification;
-        OpenflowpluginTestTopologyNotification openflowpluginTestTopologyNotification =
-                new OpenflowpluginTestTopologyNotification(notificationService);
-        this.cmdTopologyNotification = openflowpluginTestTopologyNotification;
-        OpenflowPluginBulkTransactionProvider openflowPluginBulkTransactionProvider =
-                new OpenflowPluginBulkTransactionProvider(dataBroker, ctx);
-        this.bulkCmdProvider = openflowPluginBulkTransactionProvider;
-        OpenflowPluginBulkGroupTransactionProvider openflowPluginBulkGroupTransactionProvider =
-                new OpenflowPluginBulkGroupTransactionProvider(dataBroker, ctx);
-        this.groupCmdProvider = openflowPluginBulkGroupTransactionProvider;
-    }
+        cmdProvider = new OpenflowpluginTestCommandProvider(dataBroker, notificationService, ctx);
+        cmdGroupProvider = new OpenflowpluginGroupTestCommandProvider(dataBroker, ctx);
+        cmdMeterProvider = new OpenflowpluginMeterTestCommandProvider(dataBroker, ctx);
+        cmdTableProvider = new OpenflowpluginTableFeaturesTestCommandProvider(dataBroker, ctx);
+        cmdStatsProvider = new OpenflowpluginStatsTestCommandProvider(dataBroker, ctx);
+        cmdNodeConnectorNotification = new OpenflowpluginTestNodeConnectorNotification(notificationService);
+        cmdTopologyNotification = new OpenflowpluginTestTopologyNotification(notificationService);
+        bulkCmdProvider = new OpenflowPluginBulkTransactionProvider(dataBroker, ctx);
+        groupCmdProvider = new OpenflowPluginBulkGroupTransactionProvider(dataBroker, ctx);
 
-    @PostConstruct
-    public void init() {
         provider.register(rpcRegistry);
 
         groupProvider.register(rpcRegistry);
         meterProvider.register(rpcRegistry);
         tableProvider.register(rpcRegistry);
 
-        this.cmdProvider.init();
-        this.cmdGroupProvider.init();
-        this.cmdMeterProvider.init();
-        this.cmdTableProvider.init();
-        this.cmdStatsProvider.init();
-        this.cmdNodeConnectorNotification.init();
-        this.cmdTopologyNotification.init();
-        this.bulkCmdProvider.init();
-        this.groupCmdProvider.init();
+        cmdProvider.init();
+        cmdGroupProvider.init();
+        cmdMeterProvider.init();
+        cmdTableProvider.init();
+        cmdStatsProvider.init();
+        cmdNodeConnectorNotification.init();
+        cmdTopologyNotification.init();
+        bulkCmdProvider.init();
+        groupCmdProvider.init();
     }
 
     @Override
     @PreDestroy
-    @SuppressWarnings("checkstyle:IllegalCatch")
+    @Deactivate
     public void close() {
-        try {
-            provider.close();
-        } catch (Exception e) {
-            // TODO Auto-generated catch block
-            LOG.error("Stopping bundle OpenflowpluginTestActivator failed.", e);
-        }
+        provider.close();
     }
 }