From: Robert Varga Date: Thu, 30 Jul 2020 15:17:26 +0000 (+0200) Subject: Convert cluster-admin to OSGi DS X-Git-Tag: v2.0.4~3 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=e3f2203548b8adcde4662fc90e2aa7f245d50d81 Convert cluster-admin to OSGi DS This is a very simple component, convert it to declarative services. JIRA: CONTROLLER-1882 Change-Id: I664db0ef3cbf6b5cf900d969fa56bc04440c2604 Signed-off-by: Robert Varga --- diff --git a/opendaylight/md-sal/sal-cluster-admin-impl/pom.xml b/opendaylight/md-sal/sal-cluster-admin-impl/pom.xml index 7616575fc5..96d2dc0df8 100644 --- a/opendaylight/md-sal/sal-cluster-admin-impl/pom.xml +++ b/opendaylight/md-sal/sal-cluster-admin-impl/pom.xml @@ -93,6 +93,10 @@ org.apache.commons commons-lang3 + + org.osgi + osgi.cmpn + 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 index 0000000000..5280ad5633 --- /dev/null +++ b/opendaylight/md-sal/sal-cluster-admin-impl/src/main/java/org/opendaylight/controller/cluster/datastore/admin/OSGiClusterAdmin.java @@ -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 index 258bc09955..0000000000 --- a/opendaylight/md-sal/sal-cluster-admin-impl/src/main/resources/OSGI-INF/blueprint/cluster-admin.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file