2 * Copyright (c) 2016 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
9 package org.opendaylight.netconf.util.osgi;
11 import java.util.Hashtable;
12 import org.osgi.framework.BundleActivator;
13 import org.osgi.framework.BundleContext;
14 import org.osgi.framework.Constants;
15 import org.osgi.framework.ServiceRegistration;
16 import org.osgi.service.cm.ManagedService;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
20 public class NetconfConfigurationActivator implements BundleActivator {
21 private static final Logger LOG = LoggerFactory.getLogger(NetconfConfigurationActivator.class);
23 // This has to match netconf config filename without .cfg suffix
24 private static final String CONFIG_PID = "netconf";
25 private static final Hashtable<String, String> PROPS = new Hashtable<>(1);
28 PROPS.put(Constants.SERVICE_PID, CONFIG_PID);
31 private ServiceRegistration<?> configService;
34 public void start(final BundleContext bundleContext) {
35 LOG.debug("Starting netconf configuration service");
36 configService = bundleContext.registerService(ManagedService.class,
37 new NetconfConfiguration(), PROPS);
41 public void stop(final BundleContext bundleContext) {
42 if (configService != null) {
43 LOG.debug("Unregistering netconf configuration service");
44 configService.unregister();