Code polish
This commit is contained in:
parent
fc28153ed4
commit
e7a7ec9737
@ -71,11 +71,11 @@ internal class RmiManagerConnections<CONNECTION: Connection>(logger: KLogger,
|
|||||||
/**
|
/**
|
||||||
* on the "client" to create a connection-specific remote object (that exists on the server)
|
* on the "client" to create a connection-specific remote object (that exists on the server)
|
||||||
*/
|
*/
|
||||||
suspend fun <Iface> createRemoteObject(connection: Connection, interfaceClassId: Int, objectParameters: Array<Any?>?, callback: suspend (Int, Iface) -> Unit) {
|
suspend fun <Iface> createRemoteObject(connection: Connection, kryoId: Int, objectParameters: Array<Any?>?, callback: suspend (Int, Iface) -> Unit) {
|
||||||
val callbackId = rmiGlobalSupport.registerCallback(callback)
|
val callbackId = rmiGlobalSupport.registerCallback(callback)
|
||||||
|
|
||||||
// There is no rmiID yet, because we haven't created it!
|
// There is no rmiID yet, because we haven't created it!
|
||||||
val message = ConnectionObjectCreateRequest(RmiUtils.packShorts(interfaceClassId, callbackId), objectParameters)
|
val message = ConnectionObjectCreateRequest(RmiUtils.packShorts(kryoId, callbackId), objectParameters)
|
||||||
|
|
||||||
// We use a callback to notify us when the object is ready. We can't "create this on the fly" because we
|
// We use a callback to notify us when the object is ready. We can't "create this on the fly" because we
|
||||||
// have to wait for the object to be created + ID to be assigned on the remote system BEFORE we can create the proxy instance here.
|
// have to wait for the object to be created + ID to be assigned on the remote system BEFORE we can create the proxy instance here.
|
||||||
@ -89,12 +89,12 @@ internal class RmiManagerConnections<CONNECTION: Connection>(logger: KLogger,
|
|||||||
*/
|
*/
|
||||||
suspend fun onConnectionObjectCreateRequest(endPoint: EndPoint<CONNECTION>, connection: CONNECTION, message: ConnectionObjectCreateRequest) {
|
suspend fun onConnectionObjectCreateRequest(endPoint: EndPoint<CONNECTION>, connection: CONNECTION, message: ConnectionObjectCreateRequest) {
|
||||||
|
|
||||||
val interfaceClassId = RmiUtils.unpackLeft(message.packedIds)
|
val kryoId = RmiUtils.unpackLeft(message.packedIds)
|
||||||
val callbackId = RmiUtils.unpackRight(message.packedIds)
|
val callbackId = RmiUtils.unpackRight(message.packedIds)
|
||||||
val objectParameters = message.objectParameters
|
val objectParameters = message.objectParameters
|
||||||
|
|
||||||
// We have to lookup the iface, since the proxy object requires it
|
// We have to lookup the iface, since the proxy object requires it
|
||||||
val implObject = endPoint.serialization.createRmiObject(interfaceClassId, objectParameters)
|
val implObject = endPoint.serialization.createRmiObject(kryoId, objectParameters)
|
||||||
|
|
||||||
val response = if (implObject is Exception) {
|
val response = if (implObject is Exception) {
|
||||||
// whoops!
|
// whoops!
|
||||||
|
@ -62,8 +62,8 @@ internal class RmiManagerGlobal<CONNECTION : Connection>(logger: KLogger,
|
|||||||
|
|
||||||
// duplicates are fine, as they represent the same object (as specified by the ID) on the remote side.
|
// duplicates are fine, as they represent the same object (as specified by the ID) on the remote side.
|
||||||
|
|
||||||
val classId = serialization.getClassId(interfaceClass)
|
val kryoClassId = serialization.getKryoIdForRmi(interfaceClass)
|
||||||
val cachedMethods = serialization.getMethods(classId)
|
val cachedMethods = serialization.getMethods(kryoClassId)
|
||||||
|
|
||||||
val name = "<${connection.endPoint().type.simpleName}-proxy #$rmiId>"
|
val name = "<${connection.endPoint().type.simpleName}-proxy #$rmiId>"
|
||||||
|
|
||||||
|
@ -31,8 +31,9 @@ internal class ClassRegistrationIfaceAndImpl(val ifaceClass: Class<*>,
|
|||||||
id = registration.id
|
id = registration.id
|
||||||
|
|
||||||
// override that registration
|
// override that registration
|
||||||
kryo.register(implClass, serializer, id).id
|
kryo.register(implClass, serializer, id)
|
||||||
} else {
|
} else {
|
||||||
|
// now register the impl class
|
||||||
id = kryo.register(implClass, serializer).id
|
id = kryo.register(implClass, serializer).id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user