2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.sal.restconf.broker.osgi;
10 import java.util.Hashtable;
11 import javassist.ClassPool;
12 import org.opendaylight.yangtools.sal.binding.generator.impl.RuntimeGeneratedMappingServiceImpl;
13 import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
14 import org.osgi.framework.BundleActivator;
15 import org.osgi.framework.BundleContext;
16 import org.osgi.framework.ServiceRegistration;
18 public class Activator implements BundleActivator {
20 private ServiceRegistration<BindingIndependentMappingService> mappingReg;
23 public void start(BundleContext context) throws Exception {
24 RuntimeGeneratedMappingServiceImpl service = new RuntimeGeneratedMappingServiceImpl();
25 service.setPool(new ClassPool());
27 startRuntimeMappingService(service, context);
30 private void startRuntimeMappingService(RuntimeGeneratedMappingServiceImpl service, BundleContext context) {
31 Hashtable<String, String> properties = new Hashtable<String, String>();
32 mappingReg = context.registerService(BindingIndependentMappingService.class, service, properties);
36 public void stop(BundleContext context) throws Exception {
37 if(mappingReg != null) {
38 mappingReg.unregister();