Merge "AAI services registration in MSB/HEAT"
[demo.git] / vnfs / vLBMS / apis / vlb-business-vnf-onap-plugin-impl / src / main / java / org / onap / vnf / vlb / write / ModuleWriterFactory.java
1 /*
2  * Copyright (c) 2016 Cisco and/or its affiliates.
3  *
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:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 package org.onap.vnf.vlb.write;
18
19 import static org.onap.vnf.vlb.ModuleConfiguration.ELEMENT_SERVICE_NAME;
20
21 import com.google.inject.Inject;
22 import com.google.inject.name.Named;
23 import org.onap.vnf.vlb.CrudService;
24 import io.fd.honeycomb.translate.impl.write.GenericWriter;
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.vlb.business.vnf.onap.plugin.rev160918.VlbBusinessVnfOnapPlugin;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vlb.business.vnf.onap.plugin.rev160918.vlb.business.vnf.onap.plugin.params.VdnsInstances;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vlb.business.vnf.onap.plugin.rev160918.vlb.business.vnf.onap.plugin.params.vdns.instances.VdnsInstance;
31 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
32
33 /**
34  * Factory producing writers for vlb-business-vnf-onap-plugin plugin's data.
35  */
36 public final class ModuleWriterFactory implements WriterFactory {
37
38     private static final InstanceIdentifier<VlbBusinessVnfOnapPlugin> ROOT_CONTAINER_ID = InstanceIdentifier.create(VlbBusinessVnfOnapPlugin.class);
39
40     /**
41      * Injected crud service to be passed to customizers instantiated in this factory.
42      */
43     @Inject
44     @Named(ELEMENT_SERVICE_NAME)
45     private CrudService<VdnsInstance> crudService;
46
47     @Override
48     public void init(@Nonnull final ModifiableWriterRegistryBuilder registry) {
49
50         //adds writer for child node
51         //no need to add writers for empty nodes
52         registry.add(new GenericWriter<>(ROOT_CONTAINER_ID.child(VdnsInstances.class).child(VdnsInstance.class), new ElementCustomizer(crudService)));
53     }
54 }