Allow services to be loaded as a resources as well as a file.

This commit is contained in:
Chris Rankin 2017-01-31 09:47:54 +00:00
parent 10061107df
commit 0bdd8c23b6

View File

@ -1,7 +1,8 @@
package net.corda.demobench.model package net.corda.demobench.model
import tornadofx.Controller import tornadofx.Controller
import java.io.File import java.io.InputStreamReader
import java.net.URL
import java.util.* import java.util.*
class ServiceController : Controller() { class ServiceController : Controller() {
@ -11,9 +12,9 @@ class ServiceController : Controller() {
val services : List<String> val services : List<String>
get() = serviceSet get() = serviceSet
private fun loadConf(name: String): List<String> { private fun loadConf(url: URL): List<String> {
val set = HashSet<String>() val set = HashSet<String>()
File(name).readLines().forEach { InputStreamReader(url.openStream()).readLines().forEach {
val service = it.trim() val service = it.trim()
set.add(service) set.add(service)
@ -30,7 +31,7 @@ class ServiceController : Controller() {
serviceSet = if (serviceConf == null) { serviceSet = if (serviceConf == null) {
emptyList<String>() emptyList<String>()
} else { } else {
loadConf(serviceConf.file) loadConf(serviceConf)
} }
} }
} }