2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.config.yang.md.sal.dom.impl;
10 import java.util.concurrent.Executors;
12 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
13 import org.opendaylight.controller.md.sal.dom.broker.impl.DOMDataBrokerImpl;
14 import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
15 import org.opendaylight.controller.sal.core.spi.data.DOMStore;
17 import com.google.common.collect.ImmutableMap;
18 import com.google.common.util.concurrent.ListeningExecutorService;
19 import com.google.common.util.concurrent.MoreExecutors;
24 public final class DomInmemoryDataBrokerModule extends
25 org.opendaylight.controller.config.yang.md.sal.dom.impl.AbstractDomInmemoryDataBrokerModule {
27 public DomInmemoryDataBrokerModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
28 final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
29 super(identifier, dependencyResolver);
32 public DomInmemoryDataBrokerModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
33 final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
34 final DomInmemoryDataBrokerModule oldModule, final java.lang.AutoCloseable oldInstance) {
36 super(identifier, dependencyResolver, oldModule, oldInstance);
40 protected void customValidation() {
41 // Add custom validation for module attributes here.
45 public java.lang.AutoCloseable createInstance() {
46 ListeningExecutorService storeExecutor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(2));
47 //Initializing Operational DOM DataStore defaulting to InMemoryDOMDataStore if one is not configured
48 DOMStore operStore = getOperationalDataStoreDependency();
49 if(operStore == null){
50 //we will default to InMemoryDOMDataStore creation
51 operStore = new InMemoryDOMDataStore("DOM-OPER", storeExecutor);
52 //here we will register the SchemaContext listener
53 getSchemaServiceDependency().registerSchemaContextListener((InMemoryDOMDataStore)operStore);
56 DOMStore configStore = getConfigDataStoreDependency();
57 if(configStore == null){
58 //we will default to InMemoryDOMDataStore creation
59 configStore = new InMemoryDOMDataStore("DOM-CFG", storeExecutor);
60 //here we will register the SchemaContext listener
61 getSchemaServiceDependency().registerSchemaContextListener((InMemoryDOMDataStore)configStore);
63 ImmutableMap<LogicalDatastoreType, DOMStore> datastores = ImmutableMap
64 .<LogicalDatastoreType, DOMStore> builder().put(LogicalDatastoreType.OPERATIONAL, operStore)
65 .put(LogicalDatastoreType.CONFIGURATION, configStore).build();
67 DOMDataBrokerImpl newDataBroker = new DOMDataBrokerImpl(datastores, MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor()));