Merge "Remove unnecessary warn log from config subsystem"
[controller.git] / opendaylight / md-sal / sal-dom-broker / src / main / java / org / opendaylight / controller / config / yang / md / sal / dom / impl / DomBrokerImplModule.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 package org.opendaylight.controller.config.yang.md.sal.dom.impl;
9
10 import org.opendaylight.controller.config.yang.md.sal.dom.statistics.DomBrokerRuntimeMXBeanImpl;
11 import org.opendaylight.controller.sal.core.api.data.DataStore;
12 import org.opendaylight.controller.sal.dom.broker.BrokerConfigActivator;
13 import org.opendaylight.controller.sal.dom.broker.BrokerImpl;
14 import org.osgi.framework.BundleContext;
15
16 import static com.google.common.base.Preconditions.*;
17
18 /**
19 *
20 */
21 public final class DomBrokerImplModule extends org.opendaylight.controller.config.yang.md.sal.dom.impl.AbstractDomBrokerImplModule
22 {
23
24     private BundleContext bundleContext;
25
26     public DomBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
27         super(identifier, dependencyResolver);
28     }
29
30     public DomBrokerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, DomBrokerImplModule oldModule, java.lang.AutoCloseable oldInstance) {
31         super(identifier, dependencyResolver, oldModule, oldInstance);
32     }
33
34     @Override
35     public void validate(){
36         super.validate();
37         checkArgument(getDataStore() != null, "Data Store needs to be provided for DomBroker");
38     }
39     
40     @Override
41     public java.lang.AutoCloseable createInstance() {
42         final BrokerImpl broker = new BrokerImpl();
43         final BrokerConfigActivator activator = new BrokerConfigActivator();
44         final DataStore store = getDataStoreDependency();
45         activator.start(broker, store, getBundleContext());
46         
47         final DomBrokerImplRuntimeMXBean domBrokerRuntimeMXBean = new DomBrokerRuntimeMXBeanImpl(activator.getDataService());
48         getRootRuntimeBeanRegistratorWrapper().register(domBrokerRuntimeMXBean);
49         return broker;
50     }
51
52     private BundleContext getBundleContext() {
53         return this.bundleContext;
54     }
55
56     public void setBundleContext(BundleContext bundleContext) {
57         this.bundleContext = bundleContext;
58     }
59 }