Merge "Bug-835:Reserve ports should be logical ports"
[controller.git] / opendaylight / md-sal / sal-dom-broker / src / main / java / org / opendaylight / controller / config / yang / md / sal / dom / impl / DomInmemoryDataBrokerModule.java
index 696c10eb19faafc8c78ae606188211debf3e4475..d3852d28c5ba1ff9d6191f135cbcaba0c88ad2b4 100644 (file)
@@ -1,17 +1,15 @@
-/**
- * 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 com.google.common.collect.ImmutableMap;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
 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;
@@ -19,9 +17,8 @@ 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;
-import com.google.common.util.concurrent.MoreExecutors;
+import java.util.Hashtable;
+import java.util.concurrent.Executors;
 
 /**
 *
@@ -51,18 +48,30 @@ 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<LogicalDatastoreType, DOMStore> datastores = ImmutableMap
                 .<LogicalDatastoreType, DOMStore> builder().put(LogicalDatastoreType.OPERATIONAL, operStore)
                 .put(LogicalDatastoreType.CONFIGURATION, configStore).build();
 
-        DOMDataBrokerImpl newDataBroker = new DOMDataBrokerImpl(datastores, MoreExecutors.sameThreadExecutor());
+        DOMDataBrokerImpl newDataBroker = new DOMDataBrokerImpl(datastores, MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor()));
 
         getBundleContext().registerService(DOMDataBroker.class, newDataBroker, new Hashtable<String, String>());
 
-        getSchemaServiceDependency().registerSchemaServiceListener(operStore);
-        getSchemaServiceDependency().registerSchemaServiceListener(configStore);
 
         return newDataBroker;
     }