1 package org.opendaylight.controller.sal.binding.osgi;
3 import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder;
4 import org.opendaylight.yangtools.sal.binding.generator.impl.RuntimeGeneratedMappingServiceImpl;
5 import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
6 import org.opendaylight.yangtools.yang.model.api.SchemaServiceListener;
7 import org.osgi.framework.BundleActivator;
8 import org.osgi.framework.BundleContext;
9 import org.osgi.framework.ServiceRegistration;
11 import java.util.Hashtable;
13 public class Activator implements BundleActivator {
15 private ServiceRegistration<?> reg;
16 private ServiceRegistration<SchemaServiceListener> listenerReg;
17 private ServiceRegistration<BindingIndependentMappingService> mappingReg;
20 public void start(BundleContext context) throws Exception {
21 RuntimeGeneratedMappingServiceImpl service = new RuntimeGeneratedMappingServiceImpl();
22 service.setPool(SingletonHolder.CLASS_POOL);
24 startRuntimeMappingService(service, context);
27 private void startRuntimeMappingService(RuntimeGeneratedMappingServiceImpl service, BundleContext context) {
28 Hashtable<String, String> properties = new Hashtable<String, String>();
29 listenerReg = context.registerService(SchemaServiceListener.class, service, properties);
30 mappingReg = context.registerService(BindingIndependentMappingService.class, service, properties);
35 public void stop(BundleContext context) throws Exception {
36 if(listenerReg != null) {
37 listenerReg.unregister();
39 if(mappingReg != null) {
40 mappingReg.unregister();