Initial OpenECOMP Demo commit
[demo.git] / vnfs / honeycomb_plugin / sample_plugin / sample-plugin-impl / src / main / java / io / fd / honeycomb / tutorial / 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 /*
18  * Modifications copyright (c) 2017 AT&T Intellectual Property
19  */
20
21 package io.fd.honeycomb.tutorial;
22
23 import com.google.inject.AbstractModule;
24 import com.google.inject.multibindings.Multibinder;
25 import io.fd.honeycomb.data.init.DataTreeInitializer;
26 import io.fd.honeycomb.translate.read.ReaderFactory;
27 import io.fd.honeycomb.translate.v3po.util.NamingContext;
28 import io.fd.honeycomb.translate.write.WriterFactory;
29 import io.fd.honeycomb.tutorial.init.ConfigDataInitializer;
30 //import io.fd.honeycomb.tutorial.read.ModuleStateReaderFactory;
31 import io.fd.honeycomb.tutorial.write.ModuleWriterFactory;
32 import net.jmob.guice.conf.core.ConfigurationModule;
33
34 /**
35  * Module class instantiating sample-plugin plugin components.
36  */
37 public final class Module extends AbstractModule {
38
39     @Override
40     protected void configure() {
41         // requests injection of properties
42         install(ConfigurationModule.create());
43         requestInjection(ModuleConfiguration.class);
44
45         // bind naming context instance for reader and writer factories
46         // the first parameter is artificial name prefix in cases a name needs to be reconstructed for a vxlan tunnel
47         // that is present in VPP but not in Honeycomb (could be extracted into configuration)
48         // the second parameter is just the naming context ID (could be extracted into configuration)
49         binder().bind(NamingContext.class).toInstance(new NamingContext("pgstream", "pgstream-context"));
50
51         // creates reader factory binding
52         // can hold multiple binding for separate yang modules
53       //  final Multibinder<ReaderFactory> readerFactoryBinder = Multibinder.newSetBinder(binder(), ReaderFactory.class);
54       //  readerFactoryBinder.addBinding().to(ModuleStateReaderFactory.class);
55
56         // create writer factory binding
57         // can hold multiple binding for separate yang modules
58         final Multibinder<WriterFactory> writerFactoryBinder = Multibinder.newSetBinder(binder(), WriterFactory.class);
59         writerFactoryBinder.addBinding().to(ModuleWriterFactory.class);
60
61         // create initializer binding
62         // can hold multiple binding for separate yang modules
63         final Multibinder<DataTreeInitializer> initializerBinder =
64                 Multibinder.newSetBinder(binder(), DataTreeInitializer.class);
65         initializerBinder.addBinding().to(ConfigDataInitializer.class);
66
67         // Disable notification producer for now
68 //        Multibinder.newSetBinder(binder(), ManagedNotificationProducer.class).addBinding()
69 //                .to(SampleNotificationProducer.class);
70     }
71 }