Convert cluster-admin to OSGi DS 73/91773/14
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 30 Jul 2020 15:17:26 +0000 (17:17 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 21 Sep 2020 18:20:07 +0000 (20:20 +0200)
This is a very simple component, convert it to declarative services.

JIRA: CONTROLLER-1882
Change-Id: I664db0ef3cbf6b5cf900d969fa56bc04440c2604
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-cluster-admin-impl/pom.xml
opendaylight/md-sal/sal-cluster-admin-impl/src/main/java/org/opendaylight/controller/cluster/datastore/admin/OSGiClusterAdmin.java [new file with mode: 0644]
opendaylight/md-sal/sal-cluster-admin-impl/src/main/resources/OSGI-INF/blueprint/cluster-admin.xml [deleted file]

index 7616575..96d2dc0 100644 (file)
       <groupId>org.apache.commons</groupId>
       <artifactId>commons-lang3</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>osgi.cmpn</artifactId>
+    </dependency>
 
   </dependencies>
 
diff --git a/opendaylight/md-sal/sal-cluster-admin-impl/src/main/java/org/opendaylight/controller/cluster/datastore/admin/OSGiClusterAdmin.java b/opendaylight/md-sal/sal-cluster-admin-impl/src/main/java/org/opendaylight/controller/cluster/datastore/admin/OSGiClusterAdmin.java
new file mode 100644 (file)
index 0000000..5280ad5
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2020 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.controller.cluster.datastore.admin;
+
+import com.google.common.annotations.Beta;
+import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.admin.rev151013.ClusterAdminService;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
+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;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Beta
+@Component(immediate = true)
+public final class OSGiClusterAdmin {
+    private static final Logger LOG = LoggerFactory.getLogger(OSGiClusterAdmin.class);
+
+    @Reference(target = "(type=distributed-config)")
+    DistributedDataStoreInterface configDatastore = null;
+    @Reference(target = "(type=distributed-operational)")
+    DistributedDataStoreInterface operDatastore = null;
+    @Reference
+    BindingNormalizedNodeSerializer serializer = null;
+    @Reference
+    RpcProviderService rpcProviderService = null;
+
+    private ObjectRegistration<?> reg;
+
+    @Activate
+    void activate() {
+        reg = rpcProviderService.registerRpcImplementation(ClusterAdminService.class,
+            new ClusterAdminRpcService(configDatastore, operDatastore, serializer));
+        LOG.info("Cluster Admin services started");
+    }
+
+    @Deactivate
+    void deactivate() {
+        reg.close();
+        LOG.info("Cluster Admin services stopped");
+    }
+}
diff --git a/opendaylight/md-sal/sal-cluster-admin-impl/src/main/resources/OSGI-INF/blueprint/cluster-admin.xml b/opendaylight/md-sal/sal-cluster-admin-impl/src/main/resources/OSGI-INF/blueprint/cluster-admin.xml
deleted file mode 100644 (file)
index 258bc09..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
-           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
-           odl:use-default-for-reference-types="true">
-
-  <!-- ClusterAdminRpcService -->
-
-  <reference id="configDatastore" interface="org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface"
-      odl:type="distributed-config"/>
-
-  <reference id="operationalDatastore" interface="org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface"
-      odl:type="distributed-operational"/>
-
-  <reference id="normalizedNodeSerializer" interface="org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer"/>
-
-  <bean id="clusterAdminService" class="org.opendaylight.controller.cluster.datastore.admin.ClusterAdminRpcService">
-    <argument ref="configDatastore"/>
-    <argument ref="operationalDatastore"/>
-    <argument ref="normalizedNodeSerializer"/>
-  </bean>
-
-  <odl:rpc-implementation ref="clusterAdminService"/>
-
-</blueprint>
\ No newline at end of file

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.