mirror of
https://github.com/corda/corda.git
synced 2024-12-24 07:06:44 +00:00
CORDA-3562: Update SandboxToStringSerializer not to need extra sandbox task. (#6149)
This commit is contained in:
parent
c4667c08e4
commit
2ab1324806
@ -1,10 +0,0 @@
|
||||
package net.corda.serialization.djvm.deserializers
|
||||
|
||||
import java.lang.reflect.Constructor
|
||||
import java.util.function.Function
|
||||
|
||||
class CreateFromString(private val factory: Constructor<Any>) : Function<String, Any> {
|
||||
override fun apply(text: String): Any {
|
||||
return factory.newInstance(text)
|
||||
}
|
||||
}
|
@ -104,9 +104,9 @@ class SandboxSerializationSchemeBuilder(
|
||||
register(SandboxMapSerializer(classLoader, taskFactory, this))
|
||||
register(SandboxEnumSerializer(classLoader, taskFactory, predicateFactory, this))
|
||||
register(SandboxPublicKeySerializer(classLoader, taskFactory))
|
||||
register(SandboxToStringSerializer(BigDecimal::class.java, classLoader, rawTaskFactory, sandboxBasicInput))
|
||||
register(SandboxToStringSerializer(BigInteger::class.java, classLoader, rawTaskFactory, sandboxBasicInput))
|
||||
register(SandboxToStringSerializer(StringBuffer::class.java, classLoader, rawTaskFactory, sandboxBasicInput))
|
||||
register(SandboxToStringSerializer(BigDecimal::class.java, classLoader, sandboxBasicInput))
|
||||
register(SandboxToStringSerializer(BigInteger::class.java, classLoader, sandboxBasicInput))
|
||||
register(SandboxToStringSerializer(StringBuffer::class.java, classLoader, sandboxBasicInput))
|
||||
register(SandboxCurrencySerializer(classLoader, taskFactory, sandboxBasicInput))
|
||||
register(SandboxX509CertificateSerializer(classLoader, taskFactory))
|
||||
register(SandboxX509CRLSerializer(classLoader, taskFactory))
|
||||
|
@ -2,7 +2,6 @@ package net.corda.serialization.djvm.serializers
|
||||
|
||||
import net.corda.core.serialization.SerializationContext
|
||||
import net.corda.djvm.rewiring.SandboxClassLoader
|
||||
import net.corda.serialization.djvm.deserializers.CreateFromString
|
||||
import net.corda.serialization.djvm.toSandboxAnyClass
|
||||
import net.corda.serialization.internal.amqp.CustomSerializer
|
||||
import net.corda.serialization.internal.amqp.DeserializationInput
|
||||
@ -10,24 +9,20 @@ import net.corda.serialization.internal.amqp.Schema
|
||||
import net.corda.serialization.internal.amqp.SerializationOutput
|
||||
import net.corda.serialization.internal.amqp.SerializationSchemas
|
||||
import org.apache.qpid.proton.codec.Data
|
||||
import java.lang.reflect.Constructor
|
||||
import java.lang.reflect.Type
|
||||
import java.util.function.Function
|
||||
|
||||
class SandboxToStringSerializer(
|
||||
unsafeClass: Class<*>,
|
||||
classLoader: SandboxClassLoader,
|
||||
rawTaskFactory: Function<in Any, out Function<in Any?, out Any?>>,
|
||||
basicInput: Function<in Any?, out Any?>
|
||||
) : CustomSerializer.Is<Any>(classLoader.toSandboxAnyClass(unsafeClass)) {
|
||||
private val creator: Function<Any?, Any?>
|
||||
private val creator: Function<in Any?, out Any?>
|
||||
|
||||
init {
|
||||
val stringClass = classLoader.loadClass("sandbox.java.lang.String")
|
||||
val createTask = classLoader.toSandboxClass(CreateFromString::class.java)
|
||||
.getConstructor(Constructor::class.java)
|
||||
.newInstance(clazz.getConstructor(stringClass))
|
||||
creator = basicInput.andThen(rawTaskFactory.apply(createTask))
|
||||
val clazzConstructor = clazz.getConstructor(stringClass)
|
||||
creator = basicInput.andThen { s -> clazzConstructor.newInstance(s) }
|
||||
}
|
||||
|
||||
override val deserializationAliases = aliasFor(unsafeClass)
|
||||
|
Loading…
Reference in New Issue
Block a user