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.config.yang.store.impl;
10 import java.util.Dictionary;
11 import java.util.Hashtable;
13 import org.opendaylight.controller.config.yang.store.api.YangStoreService;
14 import org.osgi.framework.BundleActivator;
15 import org.osgi.framework.BundleContext;
16 import org.osgi.framework.BundleEvent;
17 import org.osgi.framework.ServiceRegistration;
18 import org.osgi.util.tracker.BundleTracker;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
22 public class YangStoreActivator implements BundleActivator {
24 private BundleTracker bundleTracker;
25 private ServiceRegistration<YangStoreService> registration;
26 private static final Logger logger = LoggerFactory
27 .getLogger(YangStoreActivator.class);
30 public void start(BundleContext context) throws Exception {
31 ExtenderYangTrackerCustomizer customizerAndService = new ExtenderYangTrackerCustomizer();
32 bundleTracker = new BundleTracker(context, BundleEvent.RESOLVED | BundleEvent.UNRESOLVED, customizerAndService);
35 Dictionary<String, ?> properties = new Hashtable<>();
36 registration = context.registerService(YangStoreService.class,
37 customizerAndService, properties);
41 public void stop(BundleContext context) throws Exception {
43 bundleTracker.close();
44 } catch (Exception e) {
45 logger.warn("Exception while closing bundleTracker", e);
47 if (registration != null) {
49 registration.unregister();
50 } catch (Exception e) {
51 logger.warn("Exception while unregistring yang store service",