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 io.fd.honeycomb.lcmapi;
23 import static io.fd.honeycomb.lcmapi.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 io.fd.honeycomb.lcmapi.init.ConfigDataInitializer;
30 import io.fd.honeycomb.lcmapi.write.ModuleWriterFactory;
31 import io.fd.honeycomb.data.init.DataTreeInitializer;
32 import io.fd.honeycomb.translate.write.WriterFactory;
33 import net.jmob.guice.conf.core.ConfigurationModule;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.stream.count.rev190118.stream.count.params.Streams;
37 * Module class instantiating stream-count plugin components.
39 public final class Module extends AbstractModule {
41 // TODO This initiates all the plugin components, but it still needs to be registered/wired into an integration
42 // module producing runnable distributions. There is one such distribution in honeycomb project:
43 // vpp-integration/minimal-distribution
44 // In order to integrate this plugin with the distribution:
45 // 1. Add a dependency on this maven module to the the distribution's pom.xml
46 // 2. Add an instance of this module into the distribution in its Main class
49 protected void configure() {
50 // requests injection of properties
51 install(ConfigurationModule.create());
52 requestInjection(ModuleConfiguration.class);
54 // creates binding for interface implementation by name
55 bind(new TypeLiteral<CrudService<Streams>>(){})
56 .annotatedWith(Names.named(ELEMENT_SERVICE_NAME))
57 .to(ElementCrudService.class);
59 // create writer factory binding
60 // can hold multiple binding for separate yang modules
61 final Multibinder<WriterFactory> writerFactoryBinder = Multibinder.newSetBinder(binder(), WriterFactory.class);
62 writerFactoryBinder.addBinding().to(ModuleWriterFactory.class);
64 // create initializer binding
65 // can hold multiple binding for separate yang modules
66 final Multibinder<DataTreeInitializer> initializerBinder =
67 Multibinder.newSetBinder(binder(), DataTreeInitializer.class);
68 initializerBinder.addBinding().to(ConfigDataInitializer.class);