corda / net.corda.core.serialization / SerializationContext

SerializationContext

@DoNotImplement interface SerializationContext

Parameters to serialization and deserialization.

Types

UseCase

enum class UseCase

The use case that we are serializing for, since it influences the implementations chosen.

Properties

carpenterDisabled

abstract val carpenterDisabled: Boolean

If true, deserialization calls using this context will not fallback to using the Class Carpenter to attempt to construct classes present in the schema but not on the current classpath.

customSerializers

abstract val customSerializers: Set<SerializationCustomSerializer<*, *>>

Additional custom serializers that will be made available during (de)serialization.

deserializationClassLoader

abstract val deserializationClassLoader: ClassLoader

The class loader to use for deserialization.

encoding

abstract val encoding: SerializationEncoding?

If non-null, apply this encoding (typically compression) when serializing.

encodingWhitelist

abstract val encodingWhitelist: EncodingWhitelist

A whitelist that determines (mostly for security purposes) whether a particular encoding may be used when deserializing.

lenientCarpenterEnabled

abstract val lenientCarpenterEnabled: Boolean

If true the carpenter will happily synthesis classes that implement interfaces containing methods that are not getters for any AMQP fields. Invoking these methods will throw an AbstractMethodError. If false then an exception will be thrown during deserialization instead.

objectReferencesEnabled

abstract val objectReferencesEnabled: Boolean

Duplicate references to the same object preserved in the wire format and when deserialized when this is true, otherwise they appear as new copies of the object.

preferredSerializationVersion

abstract val preferredSerializationVersion: SerializationMagic

When serializing, use the format this header sequence represents.

preventDataLoss

abstract val preventDataLoss: Boolean

If true the serialization evolver will fail if the binary to be deserialized contains more fields then the current object from the classpath.

properties

abstract val properties: Map<Any, Any>

A map of any addition properties specific to the particular use case.

useCase

abstract val useCase: UseCase

The use case we are serializing or deserializing for. See UseCase.

whitelist

abstract val whitelist: ClassWhitelist

A whitelist that contains (mostly for security purposes) which classes can be serialized and deserialized.

Functions

withAttachmentsClassLoader

abstract fun withAttachmentsClassLoader(attachmentHashes: List<SecureHash>): SerializationContext

Does not do anything.

withClassLoader

abstract fun withClassLoader(classLoader: ClassLoader): SerializationContext

Helper method to return a new context based on this context with the deserialization class loader changed.

withCustomSerializers

abstract fun withCustomSerializers(serializers: Set<SerializationCustomSerializer<*, *>>): SerializationContext

Helper method to return a new context based on this context with the given serializers added.

withEncoding

abstract fun withEncoding(encoding: SerializationEncoding?): SerializationContext

A shallow copy of this context but with the given (possibly null) encoding.

withEncodingWhitelist

abstract fun withEncodingWhitelist(encodingWhitelist: EncodingWhitelist): SerializationContext

A shallow copy of this context but with the given encoding whitelist.

withLenientCarpenter

abstract fun withLenientCarpenter(): SerializationContext

Return a new context based on this one but with a lenient carpenter.

withPreferredSerializationVersion

abstract fun withPreferredSerializationVersion(magic: SerializationMagic): SerializationContext

Helper method to return a new context based on this context but with serialization using the format this header sequence represents.

withPreventDataLoss

abstract fun withPreventDataLoss(): SerializationContext

Return a new context based on this one but with a strict evolution.

withProperty

abstract fun withProperty(property: Any, value: Any): SerializationContext

Helper method to return a new context based on this context with the property added.

withWhitelisted

abstract fun withWhitelisted(clazz: Class<*>): SerializationContext

Helper method to return a new context based on this context with the given class specifically whitelisted.

withoutCarpenter

abstract fun withoutCarpenter(): SerializationContext

Returns a copy of the current context with carpentry of unknown classes disabled. On encountering such a class during deserialization the Serialization framework will throw a NotSerializableException.

withoutReferences

abstract fun withoutReferences(): SerializationContext

Helper method to return a new context based on this context with object references disabled.

Extension Functions

contextLogger

fun Any.contextLogger(): Logger

When called from a companion object, returns the logger for the enclosing class.

withWhitelist

fun SerializationContext.withWhitelist(classes: List<Class<*>>): SerializationContext

Helper method to return a new context based on this context with the given list of classes specifically whitelisted.