--- /dev/null
+/*
+ * 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 <T extends EventSource> EventSourceRegistration<T> 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");
+ }
+}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (c) 2017 Inocybe Technologies Inc. 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
--->
-<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">
-
- <reference id="dataBroker" interface="org.opendaylight.mdsal.binding.api.DataBroker"/>
- <reference id="consumerRegistry" interface="org.opendaylight.mdsal.binding.api.RpcConsumerRegistry"/>
- <reference id="providerRegistry" interface="org.opendaylight.mdsal.binding.api.RpcProviderService"/>
-
- <bean id="eventSourceTopology" class="org.opendaylight.controller.messagebus.app.impl.EventSourceTopology"
- destroy-method="close">
- <argument ref="dataBroker"/>
- <argument ref="providerRegistry"/>
- <argument ref="consumerRegistry"/>
- </bean>
-
- <service ref="eventSourceTopology"
- interface="org.opendaylight.controller.messagebus.spi.EventSourceRegistry"/>
-</blueprint>