HoneyNode Java 11 support for 221 devices
[transportpce.git] / tests / honeynode / 2.2.1 / honeynode-plugin-impl / src / main / java / io / fd / honeycomb / transportpce / device / write / OcPlatformWriterFactory.java
diff --git a/tests/honeynode/2.2.1/honeynode-plugin-impl/src/main/java/io/fd/honeycomb/transportpce/device/write/OcPlatformWriterFactory.java b/tests/honeynode/2.2.1/honeynode-plugin-impl/src/main/java/io/fd/honeycomb/transportpce/device/write/OcPlatformWriterFactory.java
new file mode 100644 (file)
index 0000000..042ffea
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2018 Orange and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.fd.honeycomb.transportpce.device.write;
+
+import com.google.inject.Inject;
+import com.google.inject.name.Named;
+
+import io.fd.honeycomb.translate.util.write.BindingBrokerWriter;
+import io.fd.honeycomb.translate.write.WriterFactory;
+import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder;
+
+import javax.annotation.Nonnull;
+
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.platform.rev180130.platform.component.top.Components;
+import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.org.openroadm.device.container.OrgOpenroadmDevice;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class OcPlatformWriterFactory implements WriterFactory {
+    private static final InstanceIdentifier<Components> COMPONENTS_CONTAINER_ID = InstanceIdentifier
+            .create(Components.class);
+
+
+    @Inject
+    @Named("device-databroker")
+    private DataBroker deviceDataBroker;
+
+    @Override
+    public void init(@Nonnull final ModifiableWriterRegistryBuilder registry) {
+        registry.wildcardedSubtreeAdd(new BindingBrokerWriter<>(COMPONENTS_CONTAINER_ID, deviceDataBroker));
+        deviceDataBroker.registerDataTreeChangeListener(DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION,
+                COMPONENTS_CONTAINER_ID), new ComponentsChangeListener(deviceDataBroker));
+    }
+}