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
16 import org.opendaylight.controller.sal.core.api.model.SchemaServiceListener
18 class BrokerConfigActivator implements AutoCloseable {
21 private static val ROOT = InstanceIdentifier.builder().toInstance();
23 private var ServiceRegistration<SchemaService> schemaReg;
24 private var ServiceRegistration<DataBrokerService> dataReg;
25 private var ServiceRegistration<DataProviderService> dataProviderReg;
26 private var ServiceRegistration<MountService> mountReg;
27 private var ServiceRegistration<MountProvisionService> mountProviderReg;
29 private var SchemaServiceImpl schemaService;
30 private var DataBrokerImpl dataService;
31 private var MountPointManagerImpl mountService;
33 SchemaAwareDataStoreAdapter wrappedStore
35 public def void start(BrokerImpl broker,DataStore store,BundleContext context) {
36 val emptyProperties = new Hashtable<String, String>();
37 broker.setBundleContext(context);
40 schemaService = new SchemaServiceImpl();
41 schemaService.setContext(context);
42 schemaService.setParser(new YangParserImpl());
43 schemaService.start();
44 schemaReg = context.registerService(SchemaService, schemaService, emptyProperties);
46 dataService = new DataBrokerImpl();
47 dataService.setExecutor(broker.getExecutor());
49 dataReg = context.registerService(DataBrokerService, dataService, emptyProperties);
50 dataProviderReg = context.registerService(DataProviderService, dataService, emptyProperties);
52 wrappedStore = new SchemaAwareDataStoreAdapter();
53 wrappedStore.changeDelegate(store);
54 wrappedStore.setValidationEnabled(false);
56 context.registerService(SchemaServiceListener,wrappedStore,emptyProperties)
58 dataService.registerConfigurationReader(ROOT, wrappedStore);
59 dataService.registerCommitHandler(ROOT, wrappedStore);
60 dataService.registerOperationalReader(ROOT, wrappedStore);
62 mountService = new MountPointManagerImpl();
63 mountService.setDataBroker(dataService);
65 mountReg = context.registerService(MountService, mountService, emptyProperties);
66 mountProviderReg = context.registerService(MountProvisionService, mountService, emptyProperties);
69 override def close() {
70 schemaReg?.unregister();
71 dataReg?.unregister();
72 dataProviderReg?.unregister();
73 mountReg?.unregister();
74 mountProviderReg?.unregister();