2 * Copyright (c) 2016 Cisco and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * Modifications copyright (c) 2017 AT&T Intellectual Property
20 package io.fd.honeycomb.tutorial.write;
22 import com.google.inject.Inject;
23 import io.fd.honeycomb.translate.impl.write.GenericWriter;
24 import io.fd.honeycomb.translate.v3po.util.NamingContext;
25 import io.fd.honeycomb.translate.write.WriterFactory;
26 import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder;
27 import javax.annotation.Nonnull;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.sample.plugin.rev160918.SamplePlugin;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.sample.plugin.rev160918.sample.plugin.params.PgStreams;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.sample.plugin.rev160918.sample.plugin.params.pg.streams.PgStream;
31 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
32 import org.openvpp.jvpp.core.future.FutureJVppCore;
35 * Factory producing writers for sample-plugin plugin's data.
37 public final class ModuleWriterFactory implements WriterFactory {
39 private static final InstanceIdentifier<SamplePlugin> ROOT_CONTAINER_ID = InstanceIdentifier.create(SamplePlugin.class);
42 * Injected vxlan naming context shared with writer, provided by this plugin
45 private NamingContext pgNamingContext;
47 * Injected jvpp core APIs, provided by Honeycomb's infrastructure
50 private FutureJVppCore jvppCore;
53 public void init(@Nonnull final ModifiableWriterRegistryBuilder registry) {
54 // Unlike ReaderFactory, there's no need to add structural writers, just the writers that actually do something
56 // register writer for vxlan tunnel
57 registry.add(new GenericWriter<>(
58 // What part of subtree this writer handles is identified by an InstanceIdentifier
59 ROOT_CONTAINER_ID.child(PgStreams.class).child(PgStream.class),
60 // Customizer (the actual translation code to do the heavy lifting)
61 new PgWriteCustomizer(jvppCore, pgNamingContext)));