85b0de45d81b7c12eaff9d78cd8428d7dc0909f0
[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 org.opendaylight.mdsal.binding.api.NotificationService;
13 import org.opendaylight.yangtools.concepts.ListenerRegistration;
14 import org.opendaylight.yangtools.yang.binding.NotificationListener;
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 @Beta
20 @Component(factory = OSGiNotificationService.FACTORY_NAME)
21 public final class OSGiNotificationService extends AbstractAdaptedService<NotificationService>
22         implements NotificationService {
23     // OSGi DS Component Factory name
24     static final String FACTORY_NAME = "org.opendaylight.mdsal.binding.dom.adapter.osgi.OSGiNotificationService";
25
26     public OSGiNotificationService() {
27         super(NotificationService.class);
28     }
29
30     @Override
31     public <T extends NotificationListener> ListenerRegistration<T> registerNotificationListener(final T listener) {
32         return delegate().registerNotificationListener(listener);
33     }
34
35     @Activate
36     void activate(final Map<String, ?> properties) {
37         start(properties);
38     }
39
40     @Deactivate
41     void deactivate(final int reason) {
42         stop(reason);
43     }
44 }