mirror of
https://github.com/corda/corda.git
synced 2024-12-29 09:18:58 +00:00
Allow services to be loaded as a resources as well as a file.
This commit is contained in:
parent
10061107df
commit
0bdd8c23b6
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user