Narrow Notification.implementedInterface() return type
[mdsal.git] / binding / mdsal-binding-dom-adapter / src / main / java / org / opendaylight / mdsal / binding / dom / adapter / osgi / OSGiNotificationService.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.annotations.Beta;
11 import java.util.Map;
12 import java.util.concurrent.Executor;
13 import org.opendaylight.mdsal.binding.api.NotificationService;
14 import org.opendaylight.mdsal.binding.api.NotificationService.Listener;
15 import org.opendaylight.yangtools.concepts.ListenerRegistration;
16 import org.opendaylight.yangtools.concepts.Registration;
17 import org.opendaylight.yangtools.yang.binding.DataObject;
18 import org.opendaylight.yangtools.yang.binding.Notification;
19 import org.opendaylight.yangtools.yang.binding.NotificationListener;
20 import org.osgi.service.component.annotations.Activate;
21 import org.osgi.service.component.annotations.Component;
22 import org.osgi.service.component.annotations.Deactivate;
23
24 @Beta
25 @Component(factory = OSGiNotificationService.FACTORY_NAME)
26 public final class OSGiNotificationService extends AbstractAdaptedService<NotificationService>
27         implements NotificationService {
28     // OSGi DS Component Factory name
29     static final String FACTORY_NAME = "org.opendaylight.mdsal.binding.dom.adapter.osgi.OSGiNotificationService";
30
31     public OSGiNotificationService() {
32         super(NotificationService.class);
33     }
34
35     @Override
36     public <T extends NotificationListener> ListenerRegistration<T> registerNotificationListener(final T listener) {
37         return delegate().registerNotificationListener(listener);
38     }
39
40     @Override
41     public <N extends Notification<N> & DataObject> Registration registerListener(final Class<N> type,
42             final Listener<N> listener, final Executor executor) {
43         return delegate().registerListener(type, listener, executor);
44     }
45
46     @Activate
47     void activate(final Map<String, ?> properties) {
48         start(properties);
49     }
50
51     @Deactivate
52     void deactivate(final int reason) {
53         stop(reason);
54     }
55 }