Fixed deployment of mount points (dynamic instances of MD-SAL)
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / main / java / org / opendaylight / controller / config / yang / md / sal / binding / impl / BindingBrokerImplModule.java
index c46b0dd6b4c529d00e0fae55f862f6a0229e701b..cd45f2c8b2bf8439f19bccbd4125e3eb3d253309 100644 (file)
@@ -1,48 +1,85 @@
 /**\r
-* Generated file\r
+ * Generated file\r
 \r
-* Generated from: yang module name: opendaylight-sal-binding-broker-impl  yang module local name: binding-broker-impl\r
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator\r
-* Generated at: Wed Nov 20 17:33:01 CET 2013\r
-*\r
-* Do not modify this file unless it is present under src/main directory\r
-*/\r
+ * Generated from: yang module name: opendaylight-sal-binding-broker-impl  yang module local name: binding-broker-impl\r
+ * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator\r
+ * Generated at: Wed Nov 20 17:33:01 CET 2013\r
+ *\r
+ * Do not modify this file unless it is present under src/main directory\r
+ */\r
 package org.opendaylight.controller.config.yang.md.sal.binding.impl;\r
 \r
-import org.opendaylight.controller.sal.binding.impl.BindingAwareBrokerImpl;\r
+import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder;\r
+import org.opendaylight.controller.sal.binding.impl.RootBindingAwareBroker;\r
+import org.opendaylight.controller.sal.binding.impl.RpcProviderRegistryImpl;\r
+import org.opendaylight.controller.sal.binding.impl.forward.DomForwardedBindingBrokerImpl;\r
+import org.opendaylight.controller.sal.binding.impl.forward.DomForwardingUtils;\r
 import org.osgi.framework.BundleContext;\r
 \r
-import com.google.common.base.Preconditions;\r
+import com.google.common.util.concurrent.MoreExecutors;\r
 \r
 /**\r
 *\r
 */\r
-public final class BindingBrokerImplModule extends org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractBindingBrokerImplModule {\r
+public final class BindingBrokerImplModule extends\r
+        org.opendaylight.controller.config.yang.md.sal.binding.impl.AbstractBindingBrokerImplModule {\r
 \r
     private BundleContext bundleContext;\r
 \r
-    public BindingBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {\r
+    public BindingBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,\r
+            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {\r
         super(identifier, dependencyResolver);\r
     }\r
 \r
-    public BindingBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, BindingBrokerImplModule oldModule, java.lang.AutoCloseable oldInstance) {\r
+    public BindingBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,\r
+            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,\r
+            BindingBrokerImplModule oldModule, java.lang.AutoCloseable oldInstance) {\r
         super(identifier, dependencyResolver, oldModule, oldInstance);\r
     }\r
 \r
     @Override\r
-    public void validate(){\r
+    public void validate() {\r
         super.validate();\r
     }\r
 \r
     @Override\r
     public java.lang.AutoCloseable createInstance() {\r
-        BindingAwareBrokerImpl broker = new BindingAwareBrokerImpl(getIdentifier().getInstanceName(),getBundleContext());\r
-        broker.setDataBroker(getDataBrokerDependency());\r
-        broker.setNotifyBroker(getNotificationServiceDependency());\r
+\r
+        RootBindingAwareBroker broker;\r
+        if (DomForwardingUtils.isDomForwardedBroker(getDataBrokerDependency())) {\r
+            broker = createForwardedBroker();\r
+        } else {\r
+            broker = createStandaloneBroker();\r
+        }\r
         broker.start();\r
         return broker;\r
     }\r
 \r
+    private RootBindingAwareBroker createStandaloneBroker() {\r
+        RootBindingAwareBroker broker = new RootBindingAwareBroker(getIdentifier().getInstanceName());\r
+\r
+        broker.setDataBroker(getDataBrokerDependency());\r
+        broker.setNotificationBroker(getNotificationServiceDependency());\r
+        broker.setRpcBroker(new RpcProviderRegistryImpl(broker.getIdentifier()));\r
+        return broker;\r
+    }\r
+\r
+    private RootBindingAwareBroker createForwardedBroker() {\r
+        DomForwardedBindingBrokerImpl broker = new DomForwardedBindingBrokerImpl(getIdentifier().getInstanceName());\r
+\r
+        broker.setDataBroker(getDataBrokerDependency());\r
+        broker.setNotificationBroker(getNotificationServiceDependency());\r
+        broker.setRpcBroker(new RpcProviderRegistryImpl(broker.getIdentifier()));\r
+\r
+        broker.getMountManager().setDataCommitExecutor(SingletonHolder.getDefaultCommitExecutor());\r
+        broker.getMountManager().setNotificationExecutor(SingletonHolder.getDefaultNotificationExecutor());\r
+\r
+\r
+        DomForwardingUtils.reuseForwardingFrom(broker, broker.getDataBroker());\r
+        broker.startForwarding();\r
+        return broker;\r
+    }\r
+\r
     public BundleContext getBundleContext() {\r
         return bundleContext;\r
     }\r