Bug 6023 - Adress for config subsystem netconf endpoint is not configurable
[netconf.git] / netconf / netconf-util / src / main / java / org / opendaylight / netconf / util / osgi / NetconfConfigurationActivator.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.netconf.util.osgi;
10
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
18 public class NetconfConfigurationActivator implements BundleActivator {
19     private static final String CONFIG_PID = "netconf";
20     private ServiceRegistration configService;
21
22     @Override
23     public void start(BundleContext bundleContext) {
24         configService = bundleContext.registerService(ManagedService.class,
25                 NetconfConfiguration.getInstance(), getNetconfConfigProperties());
26     }
27
28     @Override
29     public void stop(BundleContext bundleContext) {
30         if (configService != null) {
31           configService.unregister();
32           configService = null;
33         }
34     }
35
36     private Hashtable<String, String> getNetconfConfigProperties(){
37         Hashtable<String, String> properties = new Hashtable<>();
38         properties.put(Constants.SERVICE_PID, CONFIG_PID);
39         return properties;
40     }
41 }