Record deactivation reason in adapted services
[mdsal.git] / binding / mdsal-binding-dom-adapter / src / main / java / org / opendaylight / mdsal / binding / dom / adapter / osgi / OSGiActionService.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.Set;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.opendaylight.mdsal.binding.api.ActionService;
15 import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
16 import org.opendaylight.yangtools.yang.binding.Action;
17 import org.opendaylight.yangtools.yang.binding.DataObject;
18 import org.osgi.service.component.annotations.Activate;
19 import org.osgi.service.component.annotations.Component;
20 import org.osgi.service.component.annotations.Deactivate;
21
22 @Beta
23 @Component(factory = OSGiActionService.FACTORY_NAME)
24 public final class OSGiActionService extends AbstractAdaptedService<ActionService> implements ActionService {
25     // OSGi DS Component Factory name
26     static final String FACTORY_NAME = "org.opendaylight.mdsal.binding.dom.adapter.osgi.OSGiActionService";
27
28     public OSGiActionService() {
29         super(ActionService.class);
30     }
31
32     @Override
33     public <O extends @NonNull DataObject, T extends @NonNull Action<?, ?, ?>> T getActionHandle(
34             final Class<T> actionInterface, final Set<@NonNull DataTreeIdentifier<O>> validNodes) {
35         return delegate().getActionHandle(actionInterface, validNodes);
36     }
37
38     @Activate
39     void activate(final Map<String, ?> properties) {
40         start(properties);
41     }
42
43     @Deactivate
44     void deactivate(final int reason) {
45         stop(reason);
46     }
47 }