interface KtorRouter {
/**
* 路由功能
*/
fun Routing.route()
}
val reflections = Reflections("appshop.modules.sys.controller")
val subTypesOf = reflections.getSubTypesOf(KtorRouter::class.java)
if (subTypesOf.isNotEmpty()){
subTypesOf.forEach { it ->
it.kotlin.functions.find {
it.name=="route"
}?.call(it.newInstance(),routing { })
}
}
call调用扩展方法时候要传入被扩展类的实例
class demo{
fun Int.max(){
println(Int.MAX_VALUE)
}
}
@Test
fun testRoot9(){
demo::class.functions.find {
it.name=="max"
}?.call(demo(),123)
}