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

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.