Split up the parsing of the command line arguments from the parsing of the config files. (#547)

Also, the "config-file" command line argument for the doorman jar is required - it no longer defaults to network-management.conf
This commit is contained in:
Shams Asari
2018-03-14 07:01:53 +00:00
committed by GitHub
parent 4b1e0a6ffd
commit 34800ab527
24 changed files with 453 additions and 459 deletions

View File

@ -19,6 +19,7 @@ import net.corda.core.internal.uncheckedCast
import net.corda.core.utilities.NetworkHostAndPort
import org.slf4j.LoggerFactory
import java.lang.reflect.Field
import java.lang.reflect.InvocationTargetException
import java.lang.reflect.Modifier.isStatic
import java.lang.reflect.ParameterizedType
import java.net.Proxy
@ -74,19 +75,20 @@ fun <T : Any> Config.parseAs(clazz: KClass<T>, strict: Boolean = true): T {
val path = defaultToOldPath(property)
getValueInternal<Any>(path, param.type, strict)
}
return constructor.callBy(args)
try {
return constructor.callBy(args)
} catch (e: InvocationTargetException) {
throw e.cause!!
}
}
class UnknownConfigurationKeysException private constructor(val unknownKeys: Set<String>) : IllegalArgumentException(message(unknownKeys)) {
init {
require(unknownKeys.isNotEmpty()) { "Absence of unknown keys should not raise UnknownConfigurationKeysException." }
}
companion object {
fun of(offendingKeys: Set<String>): UnknownConfigurationKeysException = UnknownConfigurationKeysException(offendingKeys)
private fun message(offendingKeys: Set<String>) = "Unknown configuration keys: ${offendingKeys.joinToString(", ", "[", "]")}."
}
}