Add binding adapter components for action services
[mdsal.git] / binding / mdsal-binding-dom-adapter / src / main / java / org / opendaylight / mdsal / binding / dom / adapter / osgi / OSGiActionService.java
diff --git a/binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/osgi/OSGiActionService.java b/binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/osgi/OSGiActionService.java
new file mode 100644 (file)
index 0000000..5c7b790
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * 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.binding.dom.adapter.osgi;
+
+import com.google.common.annotations.Beta;
+import java.util.Map;
+import java.util.Set;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.mdsal.binding.api.ActionService;
+import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
+import org.opendaylight.yangtools.yang.binding.Action;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+
+@Beta
+@Component(factory = OSGiActionService.FACTORY_NAME)
+public final class OSGiActionService extends AbstractAdaptedService<ActionService> implements ActionService {
+    // OSGi DS Component Factory name
+    static final String FACTORY_NAME = "org.opendaylight.mdsal.binding.dom.adapter.osgi.OSGiActionService";
+
+    public OSGiActionService() {
+        super(ActionService.class);
+    }
+
+    @Override
+    public <O extends @NonNull DataObject, T extends @NonNull Action<?, ?, ?>> T getActionHandle(
+            final Class<T> actionInterface, final Set<@NonNull DataTreeIdentifier<O>> validNodes) {
+        return delegate().getActionHandle(actionInterface, validNodes);
+    }
+
+    @Activate
+    void activate(final Map<String, ?> properties) {
+        start(properties);
+    }
+
+    @Deactivate
+    void deactivate() {
+        stop();
+    }
+}