mirror of
https://github.com/slhaf/Partner.git
synced 2026-05-12 16:53:04 +08:00
fix(agent): add url class loader to support load external modules
This commit is contained in:
@@ -5,15 +5,22 @@ import org.reflections.scanners.Scanners
|
|||||||
import org.reflections.util.ConfigurationBuilder
|
import org.reflections.util.ConfigurationBuilder
|
||||||
import java.lang.reflect.Method
|
import java.lang.reflect.Method
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
|
import java.net.URLClassLoader
|
||||||
|
|
||||||
class AgentRegisterContext(urls: List<URL>) {
|
class AgentRegisterContext(urls: List<URL>) {
|
||||||
|
|
||||||
|
private val classLoader = URLClassLoader(
|
||||||
|
urls.toTypedArray(),
|
||||||
|
Thread.currentThread().contextClassLoader
|
||||||
|
)
|
||||||
|
|
||||||
val reflections: Reflections = Reflections(
|
val reflections: Reflections = Reflections(
|
||||||
ConfigurationBuilder().setScanners(
|
ConfigurationBuilder().setScanners(
|
||||||
Scanners.FieldsAnnotated,
|
Scanners.FieldsAnnotated,
|
||||||
Scanners.SubTypes,
|
Scanners.SubTypes,
|
||||||
Scanners.MethodsAnnotated,
|
Scanners.MethodsAnnotated,
|
||||||
Scanners.TypesAnnotated
|
Scanners.TypesAnnotated
|
||||||
).setUrls(urls)
|
).setUrls(urls).addClassLoaders(classLoader)
|
||||||
)
|
)
|
||||||
|
|
||||||
val capabilityFactoryContext: CapabilityFactoryContext = CapabilityFactoryContext()
|
val capabilityFactoryContext: CapabilityFactoryContext = CapabilityFactoryContext()
|
||||||
|
|||||||
Reference in New Issue
Block a user