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) 2019 AT&T Intellectual Property
21 package org.onap.vnf.vfw;
23 import static org.onap.vnf.vfw.ModuleConfiguration.ELEMENT_SERVICE_NAME;
25 import com.google.inject.AbstractModule;
26 import com.google.inject.TypeLiteral;
27 import com.google.inject.multibindings.Multibinder;
28 import com.google.inject.name.Names;
29 import org.onap.vnf.vfw.write.ModuleWriterFactory;
30 import io.fd.honeycomb.data.init.DataTreeInitializer;
31 import io.fd.honeycomb.translate.write.WriterFactory;
32 import net.jmob.guice.conf.core.ConfigurationModule;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.stream.count.rev190118.stream.count.params.Streams;
36 * Module class instantiating stream-count plugin components.
38 public final class Module extends AbstractModule {
40 // TODO This initiates all the plugin components, but it still needs to be registered/wired into an integration
41 // module producing runnable distributions. There is one such distribution in honeycomb project:
42 // vpp-integration/minimal-distribution
43 // In order to integrate this plugin with the distribution:
44 // 1. Add a dependency on this maven module to the the distribution's pom.xml
45 // 2. Add an instance of this module into the distribution in its Main class
48 protected void configure() {
49 // requests injection of properties
50 install(ConfigurationModule.create());
51 requestInjection(ModuleConfiguration.class);
53 // creates binding for interface implementation by name
54 bind(new TypeLiteral<CrudService<Streams>>(){})
55 .annotatedWith(Names.named(ELEMENT_SERVICE_NAME))
56 .to(ElementCrudService.class);
58 // create writer factory binding
59 // can hold multiple binding for separate yang modules
60 final Multibinder<WriterFactory> writerFactoryBinder = Multibinder.newSetBinder(binder(), WriterFactory.class);
61 writerFactoryBinder.addBinding().to(ModuleWriterFactory.class);