Honeynode test tool
[transportpce.git] / tests / honeynode / minimal-distribution-core / src / main / java / io / fd / honeycomb / infra / distro / initializer / InitializerPipelineModule.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 package io.fd.honeycomb.infra.distro.initializer;
18
19 import com.google.inject.PrivateModule;
20 import com.google.inject.Singleton;
21 import com.google.inject.name.Names;
22 import io.fd.honeycomb.data.ModifiableDataManager;
23 import io.fd.honeycomb.data.init.InitializerRegistry;
24 import io.fd.honeycomb.infra.distro.data.BindingDataBrokerProvider;
25 import io.fd.honeycomb.infra.distro.data.HoneycombDOMDataBrokerProvider;
26 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
27 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
28
29 public final class InitializerPipelineModule extends PrivateModule {
30
31     public static final String HONEYCOMB_INITIALIZER = "honeycomb-initializer";
32
33     @Override
34     protected void configure() {
35         // Create data tree manager on top of non-persisting config data tree
36         bind(ModifiableDataManager.class).toProvider(ModifiableDTDelegInitProvider.class).in(Singleton.class);
37         // Wrap as DOMDataBroker
38         bind(DOMDataBroker.class).toProvider(HoneycombDOMDataBrokerProvider.class).in(Singleton.class);
39         // Wrap as BA data broker
40         bind(DataBroker.class).annotatedWith(Names.named(HONEYCOMB_INITIALIZER))
41                 .toProvider(BindingDataBrokerProvider.class).in(Singleton.class);
42         expose(DataBroker.class).annotatedWith(Names.named(HONEYCOMB_INITIALIZER));
43
44         // Create initializer registry so that plugins can provide their initializers
45         bind(InitializerRegistry.class).annotatedWith(Names.named(HONEYCOMB_INITIALIZER))
46                 .toProvider(InitializerRegistryAdapterProvider.class).in(Singleton.class);
47         expose(InitializerRegistry.class).annotatedWith(Names.named(HONEYCOMB_INITIALIZER));
48     }
49 }