Peter Ertl
03/08/2021, 5:35 PMprivate fun instantiateAndConfigureApplication(currentClassLoader: ClassLoader): Application {
val newInstance = Application(this)
safeRiseEvent(ApplicationStarting, newInstance)
avoidingDoubleStartup {
configModulesNames.forEach { name ->
// COMMENT: this works and properly reloads the application
launchModuleByName(name, currentClassLoader, newInstance)
}
}
// COMMENT: functions like Application#initApp are initialized here and do not seem to reload (they also are not loaded by the 'currentClassLoader')
modules.forEach { it(newInstance) }
safeRiseEvent(ApplicationStarted, newInstance)
return newInstance
}
// source for configModuleNames:
private val configModulesNames: List<String> = run {
config.propertyOrNull("ktor.application.modules")?.getList() ?: emptyList()
}