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;
- }
}