X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=tests%2Fhoneynode%2F2.2.1%2Fhoneynode-plugin-impl%2Fsrc%2Fmain%2Fjava%2Fio%2Ffd%2Fhoneycomb%2Ftransportpce%2Fdevice%2Fwrite%2FOcTerminalDeviceWriterFactory.java;fp=tests%2Fhoneynode%2F2.2.1%2Fhoneynode-plugin-impl%2Fsrc%2Fmain%2Fjava%2Fio%2Ffd%2Fhoneycomb%2Ftransportpce%2Fdevice%2Fwrite%2FOcTerminalDeviceWriterFactory.java;h=ac52f3ba31a762d2613e987dc3ec8502da3e3d9f;hb=b90fdacec82f92e07d14ed1df31e3fe53275c676;hp=0000000000000000000000000000000000000000;hpb=1030996d2cfc0cec3c6c2b5d8da37c6188122372;p=transportpce.git diff --git a/tests/honeynode/2.2.1/honeynode-plugin-impl/src/main/java/io/fd/honeycomb/transportpce/device/write/OcTerminalDeviceWriterFactory.java b/tests/honeynode/2.2.1/honeynode-plugin-impl/src/main/java/io/fd/honeycomb/transportpce/device/write/OcTerminalDeviceWriterFactory.java new file mode 100644 index 000000000..ac52f3ba3 --- /dev/null +++ b/tests/honeynode/2.2.1/honeynode-plugin-impl/src/main/java/io/fd/honeycomb/transportpce/device/write/OcTerminalDeviceWriterFactory.java @@ -0,0 +1,48 @@ +/* + * 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 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.terminal.device.rev170708.terminal.device.top.TerminalDevice; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +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; + +public class OcTerminalDeviceWriterFactory implements WriterFactory { + private static final InstanceIdentifier TERMINAL_DEVICE_CONTAINER_ID = InstanceIdentifier + .create(TerminalDevice.class); + + + @Inject + @Named("device-databroker") + private DataBroker deviceDataBroker; + + @Override + public void init(@Nonnull final ModifiableWriterRegistryBuilder registry) { + registry.wildcardedSubtreeAdd(new BindingBrokerWriter<>(TERMINAL_DEVICE_CONTAINER_ID, deviceDataBroker)); + deviceDataBroker.registerDataTreeChangeListener(DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION, + TERMINAL_DEVICE_CONTAINER_ID), new TerminalDeviceChangeListener(deviceDataBroker)); + } +}