Cleaner logging of class registrations
This commit is contained in:
parent
3326fba214
commit
81302648b3
|
@ -205,9 +205,14 @@ object RmiUtils {
|
|||
cachedMethods[i] = cachedMethod
|
||||
|
||||
|
||||
if (overwrittenMethod != null && logger.isTraceEnabled) {
|
||||
logger.trace("Overridden method: ${makeFancyMethodName(cachedMethod)}")
|
||||
logger.trace(" to method: ${makeFancyMethodName(overwrittenMethod)}")
|
||||
if (overwrittenMethod != null && logger.isDebugEnabled) {
|
||||
val name = if (cachedMethod.method.declaringClass.isInterface) {
|
||||
"iface"
|
||||
} else {
|
||||
"method"
|
||||
}
|
||||
logger.debug("Overridden $name : ${makeFancyMethodName(cachedMethod)}")
|
||||
logger.debug(" to method: ${makeFancyMethodName(overwrittenMethod)}")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -447,29 +452,33 @@ object RmiUtils {
|
|||
}
|
||||
|
||||
fun makeFancyMethodName(method: CachedMethod): String {
|
||||
val parameterTypes = method.method.parameterTypes
|
||||
val size = parameterTypes.size
|
||||
val args: String = if (size == 0 || parameterTypes[size - 1] == Continuation::class.java) {
|
||||
""
|
||||
} else {
|
||||
parameterTypes.joinToString { it.simpleName }
|
||||
}
|
||||
|
||||
return "${method.method.declaringClass.name}.${method.method.name}($args)"
|
||||
return makeFancyMethodName(method.method)
|
||||
}
|
||||
|
||||
fun makeFancyMethodName(method: Method): String {
|
||||
val parameterTypes = method.parameterTypes
|
||||
val parameterTypes: Array<Class<*>> = method.parameterTypes
|
||||
val size = parameterTypes.size
|
||||
val args: String = if (size == 0 || parameterTypes[size - 1] == Continuation::class.java) {
|
||||
val isSuspend = size > 0 && parameterTypes[size - 1] == Continuation::class.java
|
||||
|
||||
val args: String = if (size == 0 || (size == 1 && isSuspend)) {
|
||||
""
|
||||
} else {
|
||||
// ALWAYS remove Continuation, since it's REALLY with "suspend" modifier)
|
||||
if (isSuspend) {
|
||||
parameterTypes.filter { it != Continuation::class.java }.joinToString { it.simpleName }
|
||||
} else {
|
||||
parameterTypes.joinToString { it.simpleName }
|
||||
}
|
||||
|
||||
return "${method.declaringClass.name}.${method.name}($args)"
|
||||
}
|
||||
|
||||
return if (isSuspend) {
|
||||
"suspend ${method.declaringClass.name}.${method.name}($args)"
|
||||
} else {
|
||||
"${method.declaringClass.name}.${method.name}($args)"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
package dorkbox.network.serialization
|
||||
|
||||
import com.esotericsoftware.kryo.Serializer
|
||||
import mu.KLogger
|
||||
|
||||
internal open class ClassRegistration(var clazz: Class<*>) {
|
||||
var id = 0
|
||||
|
@ -27,10 +26,8 @@ internal open class ClassRegistration(var clazz: Class<*>) {
|
|||
id = registration.id
|
||||
}
|
||||
|
||||
open fun log(logger: KLogger) {
|
||||
logger.trace {
|
||||
"Registered $id -> ${clazz.name}"
|
||||
}
|
||||
open fun info(): String {
|
||||
return "Registered $id -> ${clazz.name}"
|
||||
}
|
||||
|
||||
fun getInfoArray(): Array<Any> {
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
package dorkbox.network.serialization
|
||||
|
||||
import com.esotericsoftware.kryo.Serializer
|
||||
import mu.KLogger
|
||||
|
||||
internal class ClassRegistration0(clazz: Class<*>, serializer: Serializer<*>) : ClassRegistration(clazz) {
|
||||
init {
|
||||
|
@ -27,9 +26,7 @@ internal class ClassRegistration0(clazz: Class<*>, serializer: Serializer<*>) :
|
|||
id = kryo.register(clazz, serializer).id
|
||||
}
|
||||
|
||||
override fun log(logger: KLogger) {
|
||||
logger.trace {
|
||||
"Registered $id -> ${clazz.name} using ${serializer?.javaClass?.name}"
|
||||
}
|
||||
override fun info(): String {
|
||||
return "Registered $id -> ${clazz.name} using ${serializer?.javaClass?.name}"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
*/
|
||||
package dorkbox.network.serialization
|
||||
|
||||
import mu.KLogger
|
||||
|
||||
internal class ClassRegistration1(clazz: Class<*>, id: Int) : ClassRegistration(clazz) {
|
||||
init {
|
||||
this.id = id
|
||||
|
@ -26,9 +24,7 @@ internal class ClassRegistration1(clazz: Class<*>, id: Int) : ClassRegistration(
|
|||
kryo.register(clazz, id)
|
||||
}
|
||||
|
||||
override fun log(logger: KLogger) {
|
||||
logger.trace {
|
||||
"Registered $id -> (specified) ${clazz.name}"
|
||||
}
|
||||
override fun info(): String {
|
||||
return "Registered $id -> (specified) ${clazz.name}"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
package dorkbox.network.serialization
|
||||
|
||||
import com.esotericsoftware.kryo.Serializer
|
||||
import mu.KLogger
|
||||
|
||||
internal class ClassRegistration2(clazz: Class<*>, serializer: Serializer<*>, id: Int) : ClassRegistration(clazz) {
|
||||
init {
|
||||
|
@ -28,9 +27,7 @@ internal class ClassRegistration2(clazz: Class<*>, serializer: Serializer<*>, id
|
|||
kryo.register(clazz, serializer, id)
|
||||
}
|
||||
|
||||
override fun log(logger: KLogger) {
|
||||
logger.trace {
|
||||
"Registered $id -> (specified) ${clazz.name} using ${serializer?.javaClass?.name}"
|
||||
}
|
||||
override fun info(): String {
|
||||
return "Registered $id -> (specified) ${clazz.name} using ${serializer?.javaClass?.name}"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
package dorkbox.network.serialization
|
||||
|
||||
import dorkbox.network.rmi.messages.ObjectResponseSerializer
|
||||
import mu.KLogger
|
||||
|
||||
internal class ClassRegistrationIfaceAndImpl(ifaceClass: Class<*>, val implClass: Class<*>, objectResponseSerializer: ObjectResponseSerializer) : ClassRegistration(ifaceClass) {
|
||||
|
||||
|
@ -28,9 +27,7 @@ internal class ClassRegistrationIfaceAndImpl(ifaceClass: Class<*>, val implClass
|
|||
id = kryo.register(clazz, serializer).id
|
||||
}
|
||||
|
||||
override fun log(logger: KLogger) {
|
||||
logger.trace {
|
||||
"Registered $id -> (RMI) ${implClass.name}"
|
||||
}
|
||||
override fun info(): String {
|
||||
return "Registered $id -> (RMI) ${implClass.name}"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -382,14 +382,13 @@ class Serialization(private val references: Boolean,
|
|||
// now create the registration details, used to validate that the client/server have the EXACT same class registration setup
|
||||
val registrationDetails = arrayListOf<Array<Any>>()
|
||||
|
||||
if (logger.isTraceEnabled) {
|
||||
if (logger.isDebugEnabled) {
|
||||
// log the in-order output first
|
||||
classesToRegister.forEach { classRegistration ->
|
||||
classRegistration.log(logger)
|
||||
logger.debug(classRegistration.info())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
classesToRegister.forEach { classRegistration ->
|
||||
// now save all of the registration IDs for quick verification/access
|
||||
registrationDetails.add(classRegistration.getInfoArray())
|
||||
|
|
Loading…
Reference in New Issue
Block a user