fix ServiceHandler SpotBugs false positives
[transportpce.git] / tests / honeynode / 2.2.1 / honeynode-plugin-impl / src / main / java / io / fd / honeycomb / transportpce / device / DeviceModule.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 package io.fd.honeycomb.transportpce.device;
17
18 import org.opendaylight.mdsal.binding.api.DataBroker;
19 import org.opendaylight.mdsal.dom.api.DOMDataBroker;
20 import org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
23
24 import com.google.inject.PrivateModule;
25 import com.google.inject.Singleton;
26 import com.google.inject.name.Names;
27
28 import io.fd.honeycomb.infra.distro.data.DataStoreProvider;
29 import io.fd.honeycomb.infra.distro.data.InmemoryDOMDataBrokerProvider;
30 import io.fd.honeycomb.transportpce.device.configuration.DeviceConfigurationModule;
31 import io.fd.honeycomb.transportpce.device.configuration.NetconfConfigurationModule;
32 import io.fd.honeycomb.transportpce.device.configuration.OcPlatformConfigurationModule;
33 import io.fd.honeycomb.transportpce.device.configuration.OcTerminalDeviceConfigurationModule;
34 import io.fd.honeycomb.transportpce.device.configuration.PmConfigurationModule;
35
36 /**
37  * Module class instantiating device-plugin plugin components.
38  */
39
40 public final class DeviceModule extends PrivateModule {
41
42     private static final Logger LOG = LoggerFactory.getLogger(DeviceModule.class);
43     public static final String DEVICE_DATABROKER = "device-databroker";
44     public static final String DEVICE_DATABROKER_NONPERSIST = "device-databroker-nopersist";
45
46     @Override
47     protected void configure() {
48         LOG.info("Initializing Honeynode Modules");
49         // Create inmemory config data store for DEVICE
50         bind(InMemoryDOMDataStore.class).annotatedWith(Names.named(InmemoryDOMDataBrokerProvider.CONFIG))
51             .toProvider(new DataStoreProvider(InmemoryDOMDataBrokerProvider.CONFIG, org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION))
52             .in(Singleton.class);
53         // Create inmemory operational data store for DEVICE
54         bind(InMemoryDOMDataStore.class).annotatedWith(Names.named(InmemoryDOMDataBrokerProvider.OPERATIONAL))
55             .toProvider(new DataStoreProvider(InmemoryDOMDataBrokerProvider.OPERATIONAL, org.opendaylight.mdsal.common.api.LogicalDatastoreType.OPERATIONAL))
56             .in(Singleton.class);
57
58         // Wrap datastores as DOMDataBroker
59         // TODO make executor service configurable
60         bind(DOMDataBroker.class).annotatedWith(Names.named(DEVICE_DATABROKER))
61             .toProvider(InmemoryDOMDataBrokerProvider.class).in(Singleton.class);
62         expose(DOMDataBroker.class).annotatedWith(Names.named(DEVICE_DATABROKER));
63
64         // Wrap DOMDataBroker as BA data broker
65         bind(DataBroker.class).annotatedWith(Names.named(DEVICE_DATABROKER)).toProvider(DeviceBindingDataBrokerProvider.class)
66             .in(Singleton.class);
67         expose(DataBroker.class).annotatedWith(Names.named(DEVICE_DATABROKER));
68
69         //install device configuration module
70         install(new DeviceConfigurationModule());
71
72         //install pm configuration module
73         install(new PmConfigurationModule());
74         LOG.info("Device Module initialized !");
75
76         // install oc-platform configuration module
77         install(new OcPlatformConfigurationModule());
78         LOG.info("oc-platform-configuration Module initialized !");
79
80         // install oc-terminal-device configuration module
81         install(new OcTerminalDeviceConfigurationModule());
82         LOG.info("oc-terminal-device Module initialized !");
83
84         //install netconf configuration module
85         install(new NetconfConfigurationModule());
86         LOG.info("Netconf Module initialized !");
87     }
88
89 }
90