Closed nested JSON writers
[netconf.git] / netconf / netconf-util / src / main / java / org / opendaylight / netconf / util / osgi / NetconfConfigurationActivator.java
index a752322d5042131834b3f06cade1ad630c7c9f98..3c1a9c5cb06083982ae952ce36ba7a678a8a8fcb 100644 (file)
@@ -14,28 +14,35 @@ import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.cm.ManagedService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class NetconfConfigurationActivator implements BundleActivator {
+    private static final Logger LOG = LoggerFactory.getLogger(NetconfConfigurationActivator.class);
+
+    // This has to match netconf config filename without .cfg suffix
     private static final String CONFIG_PID = "netconf";
-    private ServiceRegistration configService;
+    private static final Hashtable<String, String> PROPS = new Hashtable<>(1);
+
+    static {
+        PROPS.put(Constants.SERVICE_PID, CONFIG_PID);
+    }
+
+    private ServiceRegistration<?> configService;
 
     @Override
-    public void start(BundleContext bundleContext) {
+    public void start(final BundleContext bundleContext) {
+        LOG.debug("Starting netconf configuration service");
         configService = bundleContext.registerService(ManagedService.class,
-                NetconfConfiguration.getInstance(), getNetconfConfigProperties());
+                new NetconfConfiguration(), PROPS);
     }
 
     @Override
-    public void stop(BundleContext bundleContext) {
+    public void stop(final BundleContext bundleContext) {
         if (configService != null) {
-          configService.unregister();
-          configService = null;
+            LOG.debug("Unregistering netconf configuration service");
+            configService.unregister();
+            configService = null;
         }
     }
-
-    private Hashtable<String, String> getNetconfConfigProperties(){
-        Hashtable<String, String> properties = new Hashtable<>();
-        properties.put(Constants.SERVICE_PID, CONFIG_PID);
-        return properties;
-    }
 }