Merge "Prevent ConfigPusher from killing its thread"
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / main / java / org / opendaylight / controller / config / yang / md / sal / binding / impl / BindingBrokerImplModule.java
1 /*\r
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 /**\r
9  * Generated file\r
10 \r
11  * Generated from: yang module name: opendaylight-sal-binding-broker-impl  yang module local name: binding-broker-impl\r
12  * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator\r
13  * Generated at: Wed Nov 20 17:33:01 CET 2013\r
14  *\r
15  * Do not modify this file unless it is present under src/main directory\r
16  */\r
17 package org.opendaylight.controller.config.yang.md.sal.binding.impl;\r
18 \r
19 import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder;\r
20 import org.opendaylight.controller.sal.binding.impl.RootBindingAwareBroker;\r
21 import org.opendaylight.controller.sal.binding.impl.RpcProviderRegistryImpl;\r
22 import org.opendaylight.controller.sal.binding.impl.forward.DomForwardedBindingBrokerImpl;\r
23 import org.opendaylight.controller.sal.binding.impl.forward.DomForwardingUtils;\r
24 import org.osgi.framework.BundleContext;\r
25 \r
26 import com.google.common.util.concurrent.MoreExecutors;\r
27 \r
28 /**\r
29 *\r
30 */\r
31 public final class BindingBrokerImplModule extends\r
32         org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractBindingBrokerImplModule {\r
33 \r
34     private BundleContext bundleContext;\r
35 \r
36     public BindingBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,\r
37             org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {\r
38         super(identifier, dependencyResolver);\r
39     }\r
40 \r
41     public BindingBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,\r
42             org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,\r
43             BindingBrokerImplModule oldModule, java.lang.AutoCloseable oldInstance) {\r
44         super(identifier, dependencyResolver, oldModule, oldInstance);\r
45     }\r
46 \r
47     @Override\r
48     public void validate() {\r
49         super.validate();\r
50     }\r
51 \r
52     @Override\r
53     public java.lang.AutoCloseable createInstance() {\r
54 \r
55         RootBindingAwareBroker broker;\r
56         if (DomForwardingUtils.isDomForwardedBroker(getDataBrokerDependency())) {\r
57             broker = createForwardedBroker();\r
58         } else {\r
59             broker = createStandaloneBroker();\r
60         }\r
61         broker.start();\r
62         return broker;\r
63     }\r
64 \r
65     private RootBindingAwareBroker createStandaloneBroker() {\r
66         RootBindingAwareBroker broker = new RootBindingAwareBroker(getIdentifier().getInstanceName());\r
67 \r
68         broker.setDataBroker(getDataBrokerDependency());\r
69         broker.setNotificationBroker(getNotificationServiceDependency());\r
70         broker.setRpcBroker(new RpcProviderRegistryImpl(broker.getIdentifier()));\r
71         return broker;\r
72     }\r
73 \r
74     private RootBindingAwareBroker createForwardedBroker() {\r
75         DomForwardedBindingBrokerImpl broker = new DomForwardedBindingBrokerImpl(getIdentifier().getInstanceName());\r
76 \r
77         broker.setDataBroker(getDataBrokerDependency());\r
78         broker.setNotificationBroker(getNotificationServiceDependency());\r
79         broker.setRpcBroker(new RpcProviderRegistryImpl(broker.getIdentifier()));\r
80 \r
81         broker.getMountManager().setDataCommitExecutor(SingletonHolder.getDefaultCommitExecutor());\r
82         broker.getMountManager().setNotificationExecutor(SingletonHolder.getDefaultNotificationExecutor());\r
83 \r
84 \r
85         DomForwardingUtils.reuseForwardingFrom(broker, broker.getDataBroker());\r
86         broker.startForwarding();\r
87         return broker;\r
88     }\r
89 \r
90     public BundleContext getBundleContext() {\r
91         return bundleContext;\r
92     }\r
93 \r
94     public void setBundleContext(BundleContext bundleContext) {\r
95         this.bundleContext = bundleContext;\r
96     }\r
97 }\r