mirror of
https://github.com/tursom/TursomServer.git
synced 2025-01-30 22:30:11 +08:00
add TypeAdapter
This commit is contained in:
parent
1314480e1b
commit
e3c117f126
@ -12,7 +12,6 @@ import kotlin.reflect.full.isSubclassOf
|
|||||||
|
|
||||||
object TypeAdapterFactory {
|
object TypeAdapterFactory {
|
||||||
private val adapterMap = ConcurrentSkipListMap<Int, ConcurrentLinkedQueue<TypeAdapter<*>>>()
|
private val adapterMap = ConcurrentSkipListMap<Int, ConcurrentLinkedQueue<TypeAdapter<*>>>()
|
||||||
private val adapterQueue = ConcurrentLinkedQueue<TypeAdapter<*>>()
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
scanPackage("cn.tursom.database.typeadapter")
|
scanPackage("cn.tursom.database.typeadapter")
|
||||||
@ -29,8 +28,11 @@ object TypeAdapterFactory {
|
|||||||
return queue!!
|
return queue!!
|
||||||
}
|
}
|
||||||
|
|
||||||
fun scanPackage(pkg: String) {
|
fun scanPackage(
|
||||||
getClassByPackage(pkg).forEach {
|
pkg: String,
|
||||||
|
classLoader: ClassLoader = this.javaClass.classLoader
|
||||||
|
) {
|
||||||
|
classLoader.getClassByPackage(pkg).forEach {
|
||||||
try {
|
try {
|
||||||
val clazz = Class.forName(it).kotlin
|
val clazz = Class.forName(it).kotlin
|
||||||
if (clazz.isSubclassOf(TypeAdapter::class)) {
|
if (clazz.isSubclassOf(TypeAdapter::class)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user