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.manager.impl.osgi;
10 import java.lang.management.ManagementFactory;
12 import javax.management.MBeanServer;
14 import org.opendaylight.controller.config.manager.impl.ConfigRegistryImpl;
15 import org.opendaylight.controller.config.manager.impl.jmx.ConfigRegistryJMXRegistrator;
16 import org.osgi.framework.BundleActivator;
17 import org.osgi.framework.BundleContext;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
21 public class ConfigManagerActivator implements BundleActivator {
22 private static final Logger logger = LoggerFactory
23 .getLogger(ConfigManagerActivator.class);
25 private ExtenderBundleTracker extenderBundleTracker;
26 private ConfigRegistryImpl configRegistry;
27 private ConfigRegistryJMXRegistrator configRegistryJMXRegistrator;
30 public void start(BundleContext context) throws Exception {
31 extenderBundleTracker = new ExtenderBundleTracker(context);
32 extenderBundleTracker.open();
33 BundleContextBackedModuleFactoriesResolver bundleContextBackedModuleFactoriesResolver = new BundleContextBackedModuleFactoriesResolver(
36 MBeanServer configMBeanServer = ManagementFactory
37 .getPlatformMBeanServer();
38 configRegistry = new ConfigRegistryImpl(
39 bundleContextBackedModuleFactoriesResolver, context,
41 // register config registry to jmx
43 configRegistryJMXRegistrator = new ConfigRegistryJMXRegistrator(
45 configRegistryJMXRegistrator.registerToJMX(configRegistry);
49 public void stop(BundleContext context) throws Exception {
51 configRegistry.close();
52 } catch (Exception e) {
53 logger.warn("Exception while closing config registry", e);
56 extenderBundleTracker.close();
57 } catch (Exception e) {
58 logger.warn("Exception while closing extender", e);
61 configRegistryJMXRegistrator.close();
62 } catch (Exception e) {
64 "Exception while closing config registry jmx registrator",