2bab4dbd26ca5896f3703978171e5ff72274b9db
[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.yangtools.yang.parser.impl.YangParserImpl;
10 import org.osgi.framework.BundleActivator;
11 import org.osgi.framework.BundleContext;
12 import org.osgi.framework.ServiceRegistration;
13
14 public class BrokerActivator implements BundleActivator {
15
16     BrokerImpl broker;
17     private ServiceRegistration<Broker> brokerReg;
18     private ServiceRegistration<SchemaService> schemaReg;
19     private ServiceRegistration<DataBrokerService> dataReg;
20     private ServiceRegistration<DataProviderService> dataProviderReg;
21     private SchemaServiceImpl schemaService;
22     private DataBrokerImpl dataService;
23
24     @Override
25     public void start(BundleContext context) throws Exception {
26         Hashtable<String, String> emptyProperties = new Hashtable<String, String>();
27         broker = new BrokerImpl();
28         broker.setBundleContext(context);
29         brokerReg = context.registerService(Broker.class, broker, emptyProperties);
30
31         schemaService = new SchemaServiceImpl();
32         schemaService.setContext(context);
33         schemaService.setParser(new YangParserImpl());
34         schemaService.start();
35         schemaReg = context.registerService(SchemaService.class, schemaService, new Hashtable<String, String>());
36         
37         dataService = new DataBrokerImpl();
38         dataReg = context.registerService(DataBrokerService.class, dataService, emptyProperties);
39         dataProviderReg = context.registerService(DataProviderService.class, dataService, emptyProperties);
40         
41         
42     }
43
44     @Override
45     public void stop(BundleContext context) throws Exception {
46         if (brokerReg != null) {
47             brokerReg.unregister();
48         }
49     }
50 }