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
16 class BrokerConfigActivator implements AutoCloseable {
19 private static val ROOT = InstanceIdentifier.builder().toInstance();
21 private var ServiceRegistration<SchemaService> schemaReg;
22 private var ServiceRegistration<DataBrokerService> dataReg;
23 private var ServiceRegistration<DataProviderService> dataProviderReg;
24 private var ServiceRegistration<MountService> mountReg;
25 private var ServiceRegistration<MountProvisionService> mountProviderReg;
27 private var SchemaServiceImpl schemaService;
28 private var DataBrokerImpl dataService;
29 private var MountPointManagerImpl mountService;
31 public def void start(BrokerImpl broker,DataStore store,BundleContext context) {
32 val emptyProperties = new Hashtable<String, String>();
33 broker.setBundleContext(context);
36 schemaService = new SchemaServiceImpl();
37 schemaService.setContext(context);
38 schemaService.setParser(new YangParserImpl());
39 schemaService.start();
40 schemaReg = context.registerService(SchemaService, schemaService, emptyProperties);
42 dataService = new DataBrokerImpl();
43 dataService.setExecutor(broker.getExecutor());
45 dataReg = context.registerService(DataBrokerService, dataService, emptyProperties);
46 dataProviderReg = context.registerService(DataProviderService, dataService, emptyProperties);
48 dataService.registerConfigurationReader(ROOT, store);
49 dataService.registerCommitHandler(ROOT, store);
50 dataService.registerOperationalReader(ROOT, store);
52 mountService = new MountPointManagerImpl();
53 mountService.setDataBroker(dataService);
55 mountReg = context.registerService(MountService, mountService, emptyProperties);
56 mountProviderReg = context.registerService(MountProvisionService, mountService, emptyProperties);
59 override def close() {
60 schemaReg?.unregister();
61 dataReg?.unregister();
62 dataProviderReg?.unregister();
63 mountReg?.unregister();
64 mountProviderReg?.unregister();