Updated MountPoint implementation
[controller.git] / opendaylight / md-sal / sal-dom-broker / src / main / java / org / opendaylight / controller / sal / dom / broker / BrokerActivator.java
1 package org.opendaylight.controller.sal.dom.broker;
2
3 import java.util.Hashtable;
4
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.yangtools.yang.parser.impl.YangParserImpl;
12 import org.osgi.framework.BundleActivator;
13 import org.osgi.framework.BundleContext;
14 import org.osgi.framework.ServiceRegistration;
15
16 public class BrokerActivator implements BundleActivator {
17
18     BrokerImpl broker;
19     private ServiceRegistration<Broker> brokerReg;
20     private ServiceRegistration<SchemaService> schemaReg;
21     private ServiceRegistration<DataBrokerService> dataReg;
22     private ServiceRegistration<DataProviderService> dataProviderReg;
23     private SchemaServiceImpl schemaService;
24     private DataBrokerImpl dataService;
25     private MountPointManagerImpl mountService;
26     private ServiceRegistration<MountService> mountReg;
27     private ServiceRegistration<MountProvisionService> mountProviderReg;
28
29     @Override
30     public void start(BundleContext context) throws Exception {
31         Hashtable<String, String> emptyProperties = new Hashtable<String, String>();
32         broker = new BrokerImpl();
33         broker.setBundleContext(context);
34         brokerReg = context.registerService(Broker.class, broker, emptyProperties);
35
36         schemaService = new SchemaServiceImpl();
37         schemaService.setContext(context);
38         schemaService.setParser(new YangParserImpl());
39         schemaService.start();
40         schemaReg = context.registerService(SchemaService.class, schemaService, new Hashtable<String, String>());
41         
42         dataService = new DataBrokerImpl();
43         dataReg = context.registerService(DataBrokerService.class, dataService, emptyProperties);
44         dataProviderReg = context.registerService(DataProviderService.class, dataService, emptyProperties);
45         
46         mountService = new MountPointManagerImpl();
47         mountService.setDataBroker(dataService);
48         
49         mountReg = context.registerService(MountService.class, mountService, emptyProperties);
50         mountProviderReg =  context.registerService(MountProvisionService.class, mountService, emptyProperties);
51     }
52
53     @Override
54     public void stop(BundleContext context) throws Exception {
55         if (brokerReg != null) {
56             brokerReg.unregister();
57         }
58     }
59 }