From: Robert Varga Date: Thu, 30 Jul 2020 15:28:37 +0000 (+0200) Subject: Convert messagebus-impl to OSGi DS X-Git-Tag: v2.0.4~2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=4397edee182ab4b75ad741c28f3794cd7c6726bd;ds=inline Convert messagebus-impl to OSGi DS messagebus-impl is an extremely simple component, convert it to Declarative Services. JIRA: CONTROLLER-1882 Change-Id: I5131530f3ba907525a7a29775136cd5123f56f18 Signed-off-by: Robert Varga --- diff --git a/opendaylight/md-sal/messagebus-impl/pom.xml b/opendaylight/md-sal/messagebus-impl/pom.xml index 9111061891..649a1c0a0a 100644 --- a/opendaylight/md-sal/messagebus-impl/pom.xml +++ b/opendaylight/md-sal/messagebus-impl/pom.xml @@ -38,5 +38,9 @@ and is available at http://www.eclipse.org/legal/epl-v10.html org.opendaylight.controller messagebus-spi + + org.osgi + osgi.cmpn + diff --git a/opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/OSGiEventSourceRegistry.java b/opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/OSGiEventSourceRegistry.java new file mode 100644 index 0000000000..29389ab9ac --- /dev/null +++ b/opendaylight/md-sal/messagebus-impl/src/main/java/org/opendaylight/controller/messagebus/app/impl/OSGiEventSourceRegistry.java @@ -0,0 +1,60 @@ +/* + * 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.messagebus.app.impl; + +import com.google.common.annotations.Beta; +import org.opendaylight.controller.messagebus.spi.EventSource; +import org.opendaylight.controller.messagebus.spi.EventSourceRegistration; +import org.opendaylight.controller.messagebus.spi.EventSourceRegistry; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry; +import org.opendaylight.mdsal.binding.api.RpcProviderService; +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 OSGiEventSourceRegistry implements EventSourceRegistry { + private static final Logger LOG = LoggerFactory.getLogger(OSGiEventSourceRegistry.class); + + @Reference + DataBroker dataBroker; + @Reference + RpcConsumerRegistry rpcConsumerRegistry; + @Reference + RpcProviderService rpcProviderService; + + private EventSourceTopology delegate; + + @Override + public EventSourceRegistration registerEventSource(final T eventSource) { + return delegate.registerEventSource(eventSource); + } + + @Override + public void close() { + // Intentiational no-op + } + + @Activate + void activate() { + delegate = new EventSourceTopology(dataBroker, rpcProviderService, rpcConsumerRegistry); + LOG.info("Event Source Registry started"); + } + + @Deactivate + void deactivate() { + LOG.info("Event Source Registry stopping"); + delegate.close(); + LOG.info("Event Source Registry stopped"); + } +} diff --git a/opendaylight/md-sal/messagebus-impl/src/main/resources/OSGI-INF/blueprint/messagebus.xml b/opendaylight/md-sal/messagebus-impl/src/main/resources/OSGI-INF/blueprint/messagebus.xml deleted file mode 100644 index 24a20138aa..0000000000 --- a/opendaylight/md-sal/messagebus-impl/src/main/resources/OSGI-INF/blueprint/messagebus.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - -