
com.github.timofeevda.jstressy.config.internal.Activator.kt Maven / Gradle / Ivy
/*
* The MIT License (MIT)
*
* Copyright (c) 2018 Denis Timofeev
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
*
*/
package com.github.timofeevda.jstressy.config.internal
import com.github.timofeevda.jstressy.api.config.ConfigurationService
import com.github.timofeevda.jstressy.config.ConfigLoader
import com.github.timofeevda.jstressy.utils.logging.LazyLogging
import org.osgi.framework.BundleActivator
import org.osgi.framework.BundleContext
import java.io.IOException
import java.util.*
class Activator : BundleActivator {
companion object : LazyLogging()
override fun start(bundleContext: BundleContext) {
logger.info("Activating Configuration service")
val configLoader = ConfigLoader()
val configFolder = System.getProperty("configFolder")
logger.info("Reading configuration from folder $configFolder")
try {
configLoader.readConfiguration(configFolder)
} catch (e: IOException) {
logger.error("Error reading configuration file", e)
}
logger.info("Registering configuration loader")
bundleContext.registerService(ConfigurationService::class.java.name, configLoader, Hashtable())
}
override fun stop(bundleContext: BundleContext) {
logger.info("Stopping configuration loader service")
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy