Add support for providing modules written in SMNP language (LanguageModuleProvider extension class)
This commit is contained in:
@@ -3,18 +3,18 @@ package io.smnp.ext
|
||||
import org.pf4j.DefaultPluginManager
|
||||
|
||||
object DefaultModuleRegistry : ModuleRegistry {
|
||||
private val modules = mutableMapOf<String, ModuleDefinition>()
|
||||
private val modules = mutableMapOf<String, ModuleProvider>()
|
||||
init {
|
||||
val pluginManager = DefaultPluginManager()
|
||||
pluginManager.loadPlugins()
|
||||
pluginManager.startPlugins()
|
||||
|
||||
pluginManager.getExtensions(ModuleDefinition::class.java).forEach {
|
||||
pluginManager.getExtensions(ModuleProvider::class.java).forEach {
|
||||
modules[it.path] = it
|
||||
}
|
||||
}
|
||||
|
||||
override fun requestModulesForPath(path: String): ModuleDefinition {
|
||||
override fun requestModulesForPath(path: String): ModuleProvider {
|
||||
return modules[path] ?: throw RuntimeException("Module $path not found")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user