1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 00:17:11 -07:00

Better plugin class loading.

This commit is contained in:
Cedric Beust 2016-06-02 02:49:08 -08:00
parent 744f2ab052
commit 995706c8b7

View file

@ -156,10 +156,22 @@ class PluginInfo(val xml: KobaltPluginXml, val pluginClassLoader: ClassLoader?,
GuiceFactory() GuiceFactory()
} }
fun forName(className: String) = fun forName(className: String) : Class<*> {
if (pluginClassLoader != null) pluginClassLoader.loadClass(className) fun loadClass(className: String, classLoader: ClassLoader?) : Class<*>? {
else if (classLoader != null) classLoader.loadClass(className) try {
else Class.forName(className) return classLoader?.loadClass(className)
} catch(ex: ClassNotFoundException) {
return null
}
}
val result = loadClass(className, classLoader)
?: Class.forName(className)
?: loadClass(className, pluginClassLoader)
?: throw ClassNotFoundException(className)
return result
}
// //
// Populate pluginInfo with what was found in Kobalt's own kobalt-plugin.xml // Populate pluginInfo with what was found in Kobalt's own kobalt-plugin.xml