Reduce ObjectRegistration use
[mdsal.git] / binding / mdsal-binding-dom-adapter / src / main / java / org / opendaylight / mdsal / binding / dom / adapter / osgi / OSGiNotificationPublishService.java
1 /*
2  * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.mdsal.binding.dom.adapter.osgi;
9
10 import com.google.common.util.concurrent.ListenableFuture;
11 import java.util.Map;
12 import java.util.concurrent.TimeUnit;
13 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
14 import org.opendaylight.yangtools.yang.binding.Notification;
15 import org.osgi.service.component.annotations.Activate;
16 import org.osgi.service.component.annotations.Component;
17 import org.osgi.service.component.annotations.Deactivate;
18
19 @Component(factory = OSGiNotificationPublishService.FACTORY_NAME)
20 public final class OSGiNotificationPublishService extends AbstractAdaptedService<NotificationPublishService>
21         implements NotificationPublishService {
22     // OSGi DS Component Factory name
23     static final String FACTORY_NAME = "org.opendaylight.mdsal.binding.dom.adapter.osgi.OSGiNotificationPublishService";
24
25     @Activate
26     public OSGiNotificationPublishService(final Map<String, ?> properties) {
27         super(NotificationPublishService.class, properties);
28     }
29
30     @Deactivate
31     void deactivate(final int reason) {
32         stop(reason);
33     }
34
35     @Override
36     public void putNotification(final Notification<?> notification) throws InterruptedException {
37         delegate.putNotification(notification);
38     }
39
40     @Override
41     public ListenableFuture<? extends Object> offerNotification(final Notification<?> notification) {
42         return delegate.offerNotification(notification);
43     }
44
45     @Override
46     public ListenableFuture<? extends Object> offerNotification(final Notification<?> notification, final int timeout,
47             final TimeUnit unit) throws InterruptedException {
48         return delegate.offerNotification(notification, timeout, unit);
49     }
50 }