Enable disposing environment when code execution is done
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
package io.smnp.ext
|
||||
|
||||
import io.smnp.environment.Environment
|
||||
import io.smnp.error.ModuleException
|
||||
import org.pf4j.DefaultPluginManager
|
||||
|
||||
object DefaultModuleRegistry : ModuleRegistry {
|
||||
private val pluginManager = DefaultPluginManager()
|
||||
private val modules = mutableMapOf<String, ModuleProvider>()
|
||||
init {
|
||||
val pluginManager = DefaultPluginManager()
|
||||
pluginManager.loadPlugins()
|
||||
pluginManager.startPlugins()
|
||||
|
||||
@@ -20,4 +21,9 @@ object DefaultModuleRegistry : ModuleRegistry {
|
||||
}
|
||||
|
||||
override fun registeredModules() = modules.keys.toList()
|
||||
|
||||
override fun disposeModules(environment: Environment) {
|
||||
modules.forEach { (_, module) -> module.beforeModuleDisposal(environment) }
|
||||
pluginManager.stopPlugins()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user