Class SpecificRecordBaseSerializerStrategy
java.lang.Object
org.axonframework.serialization.avro.SpecificRecordBaseSerializerStrategy
- All Implemented Interfaces:
Predicate<Class<?>>,AvroSerializerStrategy
Avro serializer strategy responsible for operations on
SpecificRecordBase.- Since:
- 4.11.0
- Author:
- Simon Zambrovski, Jan Galinski
-
Constructor Summary
ConstructorsConstructorDescriptionSpecificRecordBaseSerializerStrategy(org.apache.avro.message.SchemaStore schemaStore, RevisionResolver revisionResolver, SchemaIncompatibilityChecker schemaIncompatibilityChecker) Constructs avro serialization strategy supporting serialization and deserialization of Java Avro classes extendingSpecificRecordBase. -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyConfig(AvroSerializerStrategyConfig avroSerializerStrategyConfig) Sets the configuration for the strategy.<T> TdeserializeFromGenericRecord(SerializedObject<org.apache.avro.generic.GenericRecord> serializedObject, Class<T> readerType) Deserializes from Apache Avro generic record (intermediate representation).<T> TdeserializeFromSingleObjectEncoded(SerializedObject<byte[]> serializedObject, Class<T> readerType) Deserializes from single object encoded byte array.SerializedObject<byte[]> serializeToSingleObjectEncoded(Object object) Serializes object to byte array using Avro single-object-encoding.booleanDetermines if this strategy supports givenpayloadType.
-
Constructor Details
-
SpecificRecordBaseSerializerStrategy
public SpecificRecordBaseSerializerStrategy(org.apache.avro.message.SchemaStore schemaStore, RevisionResolver revisionResolver, SchemaIncompatibilityChecker schemaIncompatibilityChecker) Constructs avro serialization strategy supporting serialization and deserialization of Java Avro classes extendingSpecificRecordBase.- Parameters:
schemaStore- schema store to resolve schema from fingerprint.revisionResolver- revision resolver to find correct revision.schemaIncompatibilityChecker- stateful utility to perform compatibility checks.
-
-
Method Details
-
serializeToSingleObjectEncoded
Description copied from interface:AvroSerializerStrategySerializes object to byte array using Avro single-object-encoding.- Specified by:
serializeToSingleObjectEncodedin interfaceAvroSerializerStrategy- Parameters:
object- object to serialize.- Returns:
- byte array.
-
deserializeFromSingleObjectEncoded
@Nonnull public <T> T deserializeFromSingleObjectEncoded(@Nonnull SerializedObject<byte[]> serializedObject, @Nonnull Class<T> readerType) Description copied from interface:AvroSerializerStrategyDeserializes from single object encoded byte array.- Specified by:
deserializeFromSingleObjectEncodedin interfaceAvroSerializerStrategy- Type Parameters:
T- payload type to deserialize to.- Parameters:
serializedObject- serialized object containing single-object-encoded bytes.readerType- class of resulting object.- Returns:
- deserialized object.
-
deserializeFromGenericRecord
@Nonnull public <T> T deserializeFromGenericRecord(@Nonnull SerializedObject<org.apache.avro.generic.GenericRecord> serializedObject, @Nonnull Class<T> readerType) Description copied from interface:AvroSerializerStrategyDeserializes from Apache Avro generic record (intermediate representation).- Specified by:
deserializeFromGenericRecordin interfaceAvroSerializerStrategy- Type Parameters:
T- payload type to deserialize to.- Parameters:
serializedObject- serialized object containing the generic record.readerType- class of resulting object.- Returns:
- deserialized object.
-
test
Description copied from interface:AvroSerializerStrategyDetermines if this strategy supports givenpayloadType. This means that we have either aSpecificRecordBasegenerated from a schema using apache-avro-maven-plugin or a kotlinx serializable class, written using avro4k.- Specified by:
testin interfaceAvroSerializerStrategy- Specified by:
testin interfacePredicate<Class<?>>- Parameters:
payloadType- The payload type of object to de-/serialize, for exampleBankAccountCreated.class.- Returns:
trueif type is supported by this strategy,falseotherwise.
-
applyConfig
Description copied from interface:AvroSerializerStrategySets the configuration for the strategy.This method is called by the
AvroSerializer.Builderduring instantiation ofAvroSerializer, passing the builder configuration to the strategy. The default implementation does nothing, but a strategy might use this method to set up internals.This method is intended to be implemented by the strategy, if it supports configuration options set by the
AvroSerializer.Builder, passed viaAvroSerializerStrategyConfig- Specified by:
applyConfigin interfaceAvroSerializerStrategy- Parameters:
avroSerializerStrategyConfig- configuration passed by the builder.
-