1 package org.opendaylight.controller.sal.dom.broker;
3 import java.util.Hashtable;
5 import org.opendaylight.controller.sal.core.api.Broker;
6 import org.opendaylight.controller.sal.core.api.data.DataBrokerService;
7 import org.opendaylight.controller.sal.core.api.data.DataProviderService;
8 import org.opendaylight.controller.sal.core.api.model.SchemaService;
9 import org.opendaylight.controller.sal.core.api.mount.MountProvisionService;
10 import org.opendaylight.controller.sal.core.api.mount.MountService;
11 import org.opendaylight.controller.sal.dom.broker.impl.HashMapDataStore;
12 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
13 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
14 import org.osgi.framework.BundleActivator;
15 import org.osgi.framework.BundleContext;
16 import org.osgi.framework.ServiceRegistration;
18 public class BrokerActivator implements BundleActivator {
20 private static final InstanceIdentifier ROOT = InstanceIdentifier.builder().toInstance();
22 private ServiceRegistration<Broker> brokerReg;
23 private ServiceRegistration<SchemaService> schemaReg;
24 private ServiceRegistration<DataBrokerService> dataReg;
25 private ServiceRegistration<DataProviderService> dataProviderReg;
26 private SchemaServiceImpl schemaService;
27 private DataBrokerImpl dataService;
28 private MountPointManagerImpl mountService;
29 private ServiceRegistration<MountService> mountReg;
30 private ServiceRegistration<MountProvisionService> mountProviderReg;
31 private HashMapDataStore hashMapStore;
34 public void start(BundleContext context) throws Exception {
35 Hashtable<String, String> emptyProperties = new Hashtable<String, String>();
36 broker = new BrokerImpl();
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.class, schemaService, new Hashtable<String, String>());
46 dataService = new DataBrokerImpl();
47 dataService.setExecutor(broker.getExecutor());
49 dataReg = context.registerService(DataBrokerService.class, dataService, emptyProperties);
50 dataProviderReg = context.registerService(DataProviderService.class, dataService, emptyProperties);
52 hashMapStore = new HashMapDataStore();
54 dataService.registerConfigurationReader(ROOT, hashMapStore);
55 dataService.registerCommitHandler(ROOT, hashMapStore);
56 dataService.registerOperationalReader(ROOT, hashMapStore);
58 mountService = new MountPointManagerImpl();
59 mountService.setDataBroker(dataService);
61 mountReg = context.registerService(MountService.class, mountService, emptyProperties);
62 mountProviderReg = context.registerService(MountProvisionService.class, mountService, emptyProperties);
64 brokerReg = context.registerService(Broker.class, broker, emptyProperties);
68 public void stop(BundleContext context) throws Exception {
69 if (brokerReg != null) {
70 brokerReg.unregister();