--- /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.mdsal.dom.broker;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import java.util.Collection;
+import java.util.concurrent.TimeUnit;
+import org.opendaylight.mdsal.dom.api.DOMNotification;
+import org.opendaylight.mdsal.dom.api.DOMNotificationListener;
+import org.opendaylight.mdsal.dom.api.DOMNotificationPublishService;
+import org.opendaylight.mdsal.dom.api.DOMNotificationService;
+import org.opendaylight.mdsal.dom.spi.DOMNotificationSubscriptionListener;
+import org.opendaylight.mdsal.dom.spi.DOMNotificationSubscriptionListenerRegistry;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+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.metatype.annotations.AttributeDefinition;
+import org.osgi.service.metatype.annotations.Designate;
+import org.osgi.service.metatype.annotations.ObjectClassDefinition;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Component(immediate = true, configurationPid = "org.opendaylight.mdsal.dom.notification", service = {
+ DOMNotificationService.class, DOMNotificationPublishService.class,
+ DOMNotificationSubscriptionListenerRegistry.class
+})
+@Designate(ocd = OSGiDOMNotificationRouter.Config.class)
+public final class OSGiDOMNotificationRouter implements DOMNotificationService, DOMNotificationPublishService,
+ DOMNotificationSubscriptionListenerRegistry {
+ @ObjectClassDefinition()
+ public @interface Config {
+ @AttributeDefinition(name = "notification-queue-depth")
+ int queueDepth() default 65536;
+ @AttributeDefinition(name = "notification-queue-spin")
+ long spinTime() default 0;
+ @AttributeDefinition(name = "notification-queue-park")
+ long parkTime() default 0;
+ }
+
+ private static final Logger LOG = LoggerFactory.getLogger(OSGiDOMNotificationRouter.class);
+
+ private DOMNotificationRouter router;
+
+ @Activate
+ void activate(final Config config) {
+ router = DOMNotificationRouter.create(config.queueDepth(), config.spinTime(), config.parkTime(),
+ TimeUnit.MILLISECONDS);
+ LOG.info("DOM Notification Router started");
+ }
+
+ @Deactivate
+ void deactivate() {
+ router.close();
+ router = null;
+ LOG.info("DOM Notification Router stopped");
+ }
+
+ @Override
+ public <L extends DOMNotificationSubscriptionListener> ListenerRegistration<L> registerSubscriptionListener(
+ final L listener) {
+ return router.registerSubscriptionListener(listener);
+ }
+
+ @Override
+ public ListenableFuture<? extends Object> putNotification(final DOMNotification notification)
+ throws InterruptedException {
+ return router.putNotification(notification);
+ }
+
+ @Override
+ public ListenableFuture<? extends Object> offerNotification(final DOMNotification notification) {
+ return router.offerNotification(notification);
+ }
+
+ @Override
+ public ListenableFuture<? extends Object> offerNotification(final DOMNotification notification,
+ final long timeout, final TimeUnit unit) throws InterruptedException {
+ return router.offerNotification(notification, timeout, unit);
+ }
+
+ @Override
+ public <T extends DOMNotificationListener> ListenerRegistration<T> registerNotificationListener(final T listener,
+ final Collection<SchemaPath> types) {
+ return router.registerNotificationListener(listener, types);
+ }
+
+ @Override
+ public <T extends DOMNotificationListener> ListenerRegistration<T> registerNotificationListener(final T listener,
+ final SchemaPath... types) {
+ return router.registerNotificationListener(listener, types);
+ }
+}
+++ /dev/null
-<?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"
- xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
- odl:restart-dependents-on-updates="false">
-
- <cm:property-placeholder persistent-id="org.opendaylight.mdsal.dom.notification" update-strategy="none">
- <cm:default-properties>
- <cm:property name="notification-queue-depth" value="65536"/>
- <cm:property name="notification-queue-spin" value="0"/>
- <cm:property name="notification-queue-park" value="0"/>
- </cm:default-properties>
- </cm:property-placeholder>
-
- <!-- DOM Notification Service -->
-
- <bean id="domNotificationRouter" class="org.opendaylight.mdsal.dom.broker.DOMNotificationRouter"
- factory-method="create">
- <argument value="${notification-queue-depth}"/>
- <argument value="${notification-queue-spin}"/>
- <argument value="${notification-queue-park}"/>
- <argument value="MILLISECONDS"/>
- </bean>
-
- <service ref="domNotificationRouter" odl:type="default">
- <interfaces>
- <value>org.opendaylight.mdsal.dom.api.DOMNotificationService</value>
- <value>org.opendaylight.mdsal.dom.api.DOMNotificationPublishService</value>
- <value>org.opendaylight.mdsal.dom.spi.DOMNotificationSubscriptionListenerRegistry</value>
- </interfaces>
- </service>
-</blueprint>