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.
17 package org.onap.vnf.health;
19 import static org.onap.vnf.health.ModuleConfiguration.ELEMENT_SERVICE_NAME;
21 import org.onap.vnf.health.read.ModuleStateReaderFactory;
23 import com.google.inject.AbstractModule;
24 import com.google.inject.TypeLiteral;
25 import com.google.inject.multibindings.Multibinder;
26 import com.google.inject.name.Names;
28 import org.onap.vnf.health.write.ModuleWriterFactory;
29 import io.fd.honeycomb.translate.read.ReaderFactory;
30 import io.fd.honeycomb.translate.write.WriterFactory;
31 import net.jmob.guice.conf.core.ConfigurationModule;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.health.vnf.onap.plugin.rev160918.health.vnf.onap.plugin.params.HealthCheck;
35 * Module class instantiating health-vnf-onap-plugin plugin components.
37 public final class Module extends AbstractModule {
39 // TODO This initiates all the plugin components, but it still needs to be registered/wired into an integration
40 // module producing runnable distributions. There is one such distribution in honeycomb project:
41 // vpp-integration/minimal-distribution
42 // In order to integrate this plugin with the distribution:
43 // 1. Add a dependency on this maven module to the the distribution's pom.xml
44 // 2. Add an instance of this module into the distribution in its Main class
47 protected void configure() {
48 // requests injection of properties
49 install(ConfigurationModule.create());
50 requestInjection(ModuleConfiguration.class);
52 // creates binding for interface implementation by name
53 bind(new TypeLiteral<CrudService<HealthCheck>>(){})
54 .annotatedWith(Names.named(ELEMENT_SERVICE_NAME))
55 .to(ElementCrudService.class);
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);
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);