1 package org.opendaylight.controller.sal.dom.broker
3 import org.osgi.framework.ServiceRegistration
4 import org.opendaylight.controller.sal.core.api.model.SchemaService
5 import org.opendaylight.controller.sal.core.api.data.DataBrokerService
6 import org.opendaylight.controller.sal.core.api.data.DataProviderService
7 import org.opendaylight.controller.sal.dom.broker.impl.HashMapDataStore
8 import org.opendaylight.controller.sal.core.api.mount.MountProvisionService
9 import org.opendaylight.controller.sal.core.api.mount.MountService
10 import org.osgi.framework.BundleContext
11 import java.util.Hashtable
12 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl
13 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier
14 import org.opendaylight.controller.sal.core.api.data.DataStore
15 import org.opendaylight.controller.sal.dom.broker.impl.SchemaAwareDataStoreAdapter
17 class BrokerConfigActivator implements AutoCloseable {
20 private static val ROOT = InstanceIdentifier.builder().toInstance();
22 private var ServiceRegistration<SchemaService> schemaReg;
23 private var ServiceRegistration<DataBrokerService> dataReg;
24 private var ServiceRegistration<DataProviderService> dataProviderReg;
25 private var ServiceRegistration<MountService> mountReg;
26 private var ServiceRegistration<MountProvisionService> mountProviderReg;
28 private var SchemaServiceImpl schemaService;
29 private var DataBrokerImpl dataService;
30 private var MountPointManagerImpl mountService;
32 SchemaAwareDataStoreAdapter wrappedStore
34 public def void start(BrokerImpl broker,DataStore store,BundleContext context) {
35 val emptyProperties = new Hashtable<String, String>();
36 broker.setBundleContext(context);
39 schemaService = new SchemaServiceImpl();
40 schemaService.setContext(context);
41 schemaService.setParser(new YangParserImpl());
42 schemaService.start();
43 schemaReg = context.registerService(SchemaService, schemaService, emptyProperties);
45 dataService = new DataBrokerImpl();
46 dataService.setExecutor(broker.getExecutor());
48 dataReg = context.registerService(DataBrokerService, dataService, emptyProperties);
49 dataProviderReg = context.registerService(DataProviderService, dataService, emptyProperties);
51 wrappedStore = new SchemaAwareDataStoreAdapter();
52 wrappedStore.changeDelegate(store);
53 wrappedStore.setValidationEnabled(false);
55 dataService.registerConfigurationReader(ROOT, wrappedStore);
56 dataService.registerCommitHandler(ROOT, wrappedStore);
57 dataService.registerOperationalReader(ROOT, wrappedStore);
59 mountService = new MountPointManagerImpl();
60 mountService.setDataBroker(dataService);
62 mountReg = context.registerService(MountService, mountService, emptyProperties);
63 mountProviderReg = context.registerService(MountProvisionService, mountService, emptyProperties);
66 override def close() {
67 schemaReg?.unregister();
68 dataReg?.unregister();
69 dataProviderReg?.unregister();
70 mountReg?.unregister();
71 mountProviderReg?.unregister();