X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-dom-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fyang%2Fmd%2Fsal%2Fdom%2Fimpl%2FDomInmemoryDataBrokerModule.java;h=69b17ee3c48aeb5aae64dc8c4b02e36abdfce7a7;hp=696c10eb19faafc8c78ae606188211debf3e4475;hb=d9827276a68c1cd79ac69e01ccc22409c8f6d18b;hpb=e27d63bdcfbfb0c1078a9c3e5aabf59ae7e2315f diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomInmemoryDataBrokerModule.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomInmemoryDataBrokerModule.java index 696c10eb19..69b17ee3c4 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomInmemoryDataBrokerModule.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomInmemoryDataBrokerModule.java @@ -1,23 +1,18 @@ -/** - * Generated file - - * Generated from: yang module name: opendaylight-sal-dom-broker-impl yang module local name: dom-inmemory-data-broker - * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator - * Generated at: Fri Mar 28 17:32:48 CET 2014 +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. * - * Do not modify this file unless it is present under src/main directory + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.controller.config.yang.md.sal.dom.impl; -import java.util.Hashtable; import java.util.concurrent.Executors; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; import org.opendaylight.controller.md.sal.dom.broker.impl.DOMDataBrokerImpl; import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore; import org.opendaylight.controller.sal.core.spi.data.DOMStore; -import org.osgi.framework.BundleContext; import com.google.common.collect.ImmutableMap; import com.google.common.util.concurrent.ListeningExecutorService; @@ -29,8 +24,6 @@ import com.google.common.util.concurrent.MoreExecutors; public final class DomInmemoryDataBrokerModule extends org.opendaylight.controller.config.yang.md.sal.dom.impl.AbstractDomInmemoryDataBrokerModule { - private BundleContext bundleContext; - public DomInmemoryDataBrokerModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { super(identifier, dependencyResolver); @@ -51,27 +44,28 @@ public final class DomInmemoryDataBrokerModule extends @Override public java.lang.AutoCloseable createInstance() { ListeningExecutorService storeExecutor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(2)); - InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("DOM-OPER", storeExecutor); - InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("DOM-CFG", storeExecutor); + //Initializing Operational DOM DataStore defaulting to InMemoryDOMDataStore if one is not configured + DOMStore operStore = getOperationalDataStoreDependency(); + if(operStore == null){ + //we will default to InMemoryDOMDataStore creation + operStore = new InMemoryDOMDataStore("DOM-OPER", storeExecutor); + //here we will register the SchemaContext listener + getSchemaServiceDependency().registerSchemaServiceListener((InMemoryDOMDataStore)operStore); + } + + DOMStore configStore = getConfigDataStoreDependency(); + if(configStore == null){ + //we will default to InMemoryDOMDataStore creation + configStore = new InMemoryDOMDataStore("DOM-CFG", storeExecutor); + //here we will register the SchemaContext listener + getSchemaServiceDependency().registerSchemaServiceListener((InMemoryDOMDataStore)configStore); + } ImmutableMap datastores = ImmutableMap . builder().put(LogicalDatastoreType.OPERATIONAL, operStore) .put(LogicalDatastoreType.CONFIGURATION, configStore).build(); - DOMDataBrokerImpl newDataBroker = new DOMDataBrokerImpl(datastores, MoreExecutors.sameThreadExecutor()); - - getBundleContext().registerService(DOMDataBroker.class, newDataBroker, new Hashtable()); - - getSchemaServiceDependency().registerSchemaServiceListener(operStore); - getSchemaServiceDependency().registerSchemaServiceListener(configStore); + DOMDataBrokerImpl newDataBroker = new DOMDataBrokerImpl(datastores, MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor())); return newDataBroker; } - - private BundleContext getBundleContext() { - return bundleContext; - } - - void setBundleContext(final BundleContext ctx) { - bundleContext = ctx; - } }