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

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.

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

Helper method to return a new context based on this context with the appropriate class loader constructed from the passed attachment identifiers. (Requires the attachment storage to have been enabled).

withClassLoader

abstract fun withClassLoader(classLoader: ClassLoader): SerializationContext

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

withEncoding

abstract fun withEncoding(encoding: SerializationEncoding?): SerializationContext

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

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.

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.

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.