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.Hashtable;
11 import java.util.concurrent.Executors;
13 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
14 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
15 import org.opendaylight.controller.md.sal.dom.broker.impl.DOMDataBrokerImpl;
16 import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
17 import org.opendaylight.controller.sal.core.spi.data.DOMStore;
18 import org.osgi.framework.BundleContext;
20 import com.google.common.collect.ImmutableMap;
21 import com.google.common.util.concurrent.ListeningExecutorService;
22 import com.google.common.util.concurrent.MoreExecutors;
27 public final class DomInmemoryDataBrokerModule extends
28 org.opendaylight.controller.config.yang.md.sal.dom.impl.AbstractDomInmemoryDataBrokerModule {
30 private BundleContext bundleContext;
32 public DomInmemoryDataBrokerModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
33 final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
34 super(identifier, dependencyResolver);
37 public DomInmemoryDataBrokerModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
38 final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
39 final DomInmemoryDataBrokerModule oldModule, final java.lang.AutoCloseable oldInstance) {
41 super(identifier, dependencyResolver, oldModule, oldInstance);
45 protected void customValidation() {
46 // Add custom validation for module attributes here.
50 public java.lang.AutoCloseable createInstance() {
51 ListeningExecutorService storeExecutor = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(2));
52 InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("DOM-OPER", storeExecutor);
53 InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("DOM-CFG", storeExecutor);
54 ImmutableMap<LogicalDatastoreType, DOMStore> datastores = ImmutableMap
55 .<LogicalDatastoreType, DOMStore> builder().put(LogicalDatastoreType.OPERATIONAL, operStore)
56 .put(LogicalDatastoreType.CONFIGURATION, configStore).build();
58 DOMDataBrokerImpl newDataBroker = new DOMDataBrokerImpl(datastores, MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor()));
60 getBundleContext().registerService(DOMDataBroker.class, newDataBroker, new Hashtable<String, String>());
62 getSchemaServiceDependency().registerSchemaServiceListener(operStore);
63 getSchemaServiceDependency().registerSchemaServiceListener(configStore);
68 private BundleContext getBundleContext() {
72 void setBundleContext(final BundleContext ctx) {