37506d1e133543e17af49d76282a14034cba4088
[demo.git] / vnfs / vLBMS / apis / vlb-business-vnf-onap-plugin-impl / src / main / java / org / onap / vnf / vlb / Module.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;
18
19 import static org.onap.vnf.vlb.ModuleConfiguration.ELEMENT_SERVICE_NAME;
20
21 import com.google.inject.AbstractModule;
22 import com.google.inject.TypeLiteral;
23 import com.google.inject.multibindings.Multibinder;
24 import com.google.inject.name.Names;
25 //import org.onap.vnf.vlb.read.ModuleStateReaderFactory;
26 import org.onap.vnf.vlb.write.ModuleWriterFactory;
27 import io.fd.honeycomb.data.init.DataTreeInitializer;
28 import io.fd.honeycomb.translate.read.ReaderFactory;
29 import io.fd.honeycomb.translate.write.WriterFactory;
30 import net.jmob.guice.conf.core.ConfigurationModule;
31 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;
32
33 /**
34  * Module class instantiating vlb-business-vnf-onap-plugin plugin components.
35  */
36 public final class Module extends AbstractModule {
37
38     // TODO This initiates all the plugin components, but it still needs to be registered/wired into an integration
39     // module producing runnable distributions. There is one such distribution in honeycomb project:
40     // vpp-integration/minimal-distribution
41     // In order to integrate this plugin with the distribution:
42     // 1. Add a dependency on this maven module to the the distribution's pom.xml
43     // 2. Add an instance of this module into the distribution in its Main class
44
45     @Override
46     protected void configure() {
47         // requests injection of properties
48         install(ConfigurationModule.create());
49         requestInjection(ModuleConfiguration.class);
50
51         // creates binding for interface implementation by name
52         bind(new TypeLiteral<CrudService<VdnsInstance>>(){})
53                 .annotatedWith(Names.named(ELEMENT_SERVICE_NAME))
54                 .to(ElementCrudService.class);
55
56         // creates reader factory binding
57         // can hold multiple binding for separate yang modules
58         //final Multibinder<ReaderFactory> readerFactoryBinder = Multibinder.newSetBinder(binder(), ReaderFactory.class);
59         //readerFactoryBinder.addBinding().to(ModuleStateReaderFactory.class);
60
61         // create writer factory binding
62         // can hold multiple binding for separate yang modules
63         final Multibinder<WriterFactory> writerFactoryBinder = Multibinder.newSetBinder(binder(), WriterFactory.class);
64         writerFactoryBinder.addBinding().to(ModuleWriterFactory.class);
65     }
66 }