Merge "Validation Issue with DlSrc,DlDst MacAddress"
[controller.git] / opendaylight / md-sal / sal-dom-broker / src / main / java / org / opendaylight / controller / sal / dom / broker / BrokerConfigActivator.xtend
1 package org.opendaylight.controller.sal.dom.broker
2
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
17
18 class BrokerConfigActivator implements AutoCloseable {
19     
20     
21     private static val ROOT = InstanceIdentifier.builder().toInstance();
22
23     @Property
24     private var DataBrokerImpl dataService;
25     
26     private var ServiceRegistration<SchemaService> schemaReg;
27     private var ServiceRegistration<DataBrokerService> dataReg;
28     private var ServiceRegistration<DataProviderService> dataProviderReg;
29     private var ServiceRegistration<MountService> mountReg;
30     private var ServiceRegistration<MountProvisionService> mountProviderReg;
31     private var SchemaServiceImpl schemaService;
32     private var MountPointManagerImpl mountService;
33     
34     SchemaAwareDataStoreAdapter wrappedStore
35
36     public def void start(BrokerImpl broker,DataStore store,BundleContext context) {
37         val emptyProperties = new Hashtable<String, String>();
38         broker.setBundleContext(context);
39         
40
41         schemaService = new SchemaServiceImpl();
42         schemaService.setContext(context);
43         schemaService.setParser(new YangParserImpl());
44         schemaService.start();
45         schemaReg = context.registerService(SchemaService, schemaService, emptyProperties);
46         
47         dataService = new DataBrokerImpl();
48         dataService.setExecutor(broker.getExecutor());
49         
50         dataReg = context.registerService(DataBrokerService, dataService, emptyProperties);
51         dataProviderReg = context.registerService(DataProviderService, dataService, emptyProperties);
52
53         wrappedStore = new SchemaAwareDataStoreAdapter();
54         wrappedStore.changeDelegate(store);
55         wrappedStore.setValidationEnabled(false);
56        
57         context.registerService(SchemaServiceListener,wrappedStore,emptyProperties)  
58         
59         dataService.registerConfigurationReader(ROOT, wrappedStore);
60         dataService.registerCommitHandler(ROOT, wrappedStore);
61         dataService.registerOperationalReader(ROOT, wrappedStore);
62         
63         mountService = new MountPointManagerImpl();
64         mountService.setDataBroker(dataService);
65         
66         mountReg = context.registerService(MountService, mountService, emptyProperties);
67         mountProviderReg =  context.registerService(MountProvisionService, mountService, emptyProperties);
68     }
69
70     override def close() {
71         schemaReg?.unregister();
72         dataReg?.unregister();
73         dataProviderReg?.unregister();
74         mountReg?.unregister();
75         mountProviderReg?.unregister();
76     }
77     
78 }