Class Jackson3Serializer.Builder
- Enclosing class:
Jackson3Serializer
Jackson3Serializer.
The RevisionResolver is defaulted to an AnnotationRevisionResolver, the Converter to a
ChainingConverter and the ClassLoader to the ClassLoader of this class.
Upon instantiation, the created ObjectMapper will have the MetaDataDeserializer registered to it. Lastly, if
the provided converter is of type ChainingConverter, the Jackson3Serializer.registerConverters(org.axonframework.serialization.ChainingConverter) is
performed to automatically add the JsonNodeToByteArrayConverter and ByteArrayToJsonNodeConverter.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Initializes aJackson3Serializeras specified through this Builder.classLoader(ClassLoader classLoader) Sets theConverterused as a converter factory providing converter instances utilized by upcasters to convert between different content types.Configures the underlyingObjectMapperto include type information when serializing Java objects into JSON by activating default typing.Disables the caching of the names for classes which couldn't be resolved to a class.Sets a customizer for theJsonMapper.Builderused to construct the finalObjectMapper.Configures the serializer to be lenient when when deserializing JSON into Java objects.revisionResolver(RevisionResolver revisionResolver) Sets theRevisionResolverused to resolve the revision from an object to be serialized.protected voidvalidate()Validates whether the fields contained in this Builder are set accordingly.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
revisionResolver
Sets theRevisionResolverused to resolve the revision from an object to be serialized. Defaults to anAnnotationRevisionResolverwhich resolves the revision based on the contents of theRevisionannotation on the serialized classes.- Parameters:
revisionResolver- aRevisionResolverused to resolve the revision from an object to be serialized- Returns:
- the current Builder instance, for fluent interfacing
-
converter
Sets theConverterused as a converter factory providing converter instances utilized by upcasters to convert between different content types. Defaults to aChainingConverter.- Parameters:
converter- aConverterused as a converter factory providing converter instances utilized by upcasters to convert between different content types- Returns:
- the current Builder instance, for fluent interfacing
-
jsonMapperBuilderCustomizer
public Jackson3Serializer.Builder jsonMapperBuilderCustomizer(Jackson3SerializerCustomizer customizer) Sets a customizer for theJsonMapper.Builderused to construct the finalObjectMapper. This customizer is called after all Axon configuration has been applied. Setting this value tonullremoves a previous customizer if any.- Parameters:
customizer- a customizer that is called just before the finalObjectMapperis constructed- Returns:
- the current Builder instance, for fluent interfacing
-
classLoader
Configures theTypeFactoryto use the givenClassLoaderwhen building theObjectMapper. This may also be done in a customizer.- Parameters:
classLoader- theClassLoaderused to load classes with when deserializing- Returns:
- the current Builder instance, for fluent interfacing
- See Also:
-
lenientDeserialization
Configures the serializer to be lenient when when deserializing JSON into Java objects. Specifically, enables theDeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAYandDeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS, and disablesDeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES. This may also be done in a customizer.- Returns:
- the current Builder instance, for fluent interfacing
-
disableCachingOfUnknownClasses
Disables the caching of the names for classes which couldn't be resolved to a class.It is recommended to disable this in case the class loading is dynamic, and classes that are not available at one point in time, may become available at any time later.
- Returns:
- the current Builder instance, for fluent interfacing
-
defaultTyping
Configures the underlyingObjectMapperto include type information when serializing Java objects into JSON by activating default typing.Specifically, it uses
withinvalid reference
ObjectMapper#activateDefaultTyping(PolymorphicTypeValidator, ObjectMapper.DefaultTyping). To comply with Jackson 3 security requirements, this enables ainvalid reference
ObjectMapper.DefaultTyping#NON_CONCRETE_AND_ARRAYSBasicPolymorphicTypeValidatorthat allows all subtypes (viaObject.classbase type validation).This allows
Collections and other non-concrete types to include type information automatically without requiringJsonTypeInfoannotations on the classes themselves.- Returns:
- the current Builder instance, for fluent interfacing
-
build
Initializes aJackson3Serializeras specified through this Builder.- Returns:
- a
Jackson3Serializeras specified through this Builder
-
validate
Validates whether the fields contained in this Builder are set accordingly.- Throws:
AxonConfigurationException- if one field is asserted to be incorrect according to the Builder's specifications
-