Skip to content

Instantly share code, notes, and snippets.

@xnull
Created March 29, 2017 11:21
Show Gist options
  • Save xnull/4b3f092dd2319b316bd6761c9f954895 to your computer and use it in GitHub Desktop.
Save xnull/4b3f092dd2319b316bd6761c9f954895 to your computer and use it in GitHub Desktop.
package com.moex.eif.cantor.backoffice.calculator.settings
import java.io.File
import java.time.Instant
import com.moex.eif.cantor.backoffice.calculator.storage.PlatformEntityDataSource
import com.moex.eif.cantor.backoffice.model.GlobalSettings
import com.netflix.archaius.api.config.SettableConfig
import com.netflix.archaius.api.{ConfigLoader, PropertyContainer}
import com.netflix.archaius.config.DefaultSettableConfig
import com.netflix.archaius.property.DefaultPropertyListener
import com.netflix.archaius.{DefaultConfigLoader, DefaultPropertyFactory}
import org.apache.spark.sql.Dataset
import scala.concurrent.duration.{Duration, _}
object config extends App {
val loaderBuilder: DefaultConfigLoader.Builder = DefaultConfigLoader.builder()
val loader: DefaultConfigLoader = loaderBuilder.build()
val cfgLoader: ConfigLoader.Loader = loader.newLoader()//.withOverrides(new DefaultSettableConfig)
val cfgReadOnly = cfgLoader.load(new File("version.properties"))
val cfg: SettableConfig = new DefaultSettableConfig(cfgReadOnly)
//val cfg: SettableConfig = cfgReadOnly.asInstanceOf[SettableConfig]
cfg.setProperties(cfgReadOnly)
private val propFactory: DefaultPropertyFactory = DefaultPropertyFactory.from(cfg)
val propContainer: PropertyContainer = propFactory.getProperty("version")
val prop = propContainer.asString("")
prop.addListener(new DefaultPropertyListener[String] {
var firstTime = true
override def onChange(value: String): Unit = {
if (firstTime) {
firstTime = !firstTime
} else {
println("OnChange property (version) value: " + value)
}
}
})
cfg.setProperty("version", "123")
//println("!!!!")
//println(cfg.get(classOf[String], "version"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment