Class JsonSchemaKafkaSerializer<T>
- java.lang.Object
-
- io.apicurio.registry.serde.SchemaResolverConfigurer<T,U>
-
- io.apicurio.registry.serde.AbstractKafkaSerDe<T,U>
-
- io.apicurio.registry.serde.AbstractKafkaSerializer<JsonSchema,T>
-
- io.apicurio.registry.serde.jsonschema.JsonSchemaKafkaSerializer<T>
-
- All Implemented Interfaces:
Closeable,AutoCloseable,org.apache.kafka.common.serialization.Serializer<T>
public class JsonSchemaKafkaSerializer<T> extends AbstractKafkaSerializer<JsonSchema,T> implements org.apache.kafka.common.serialization.Serializer<T>
An implementation of the Kafka Serializer for JSON Schema use-cases. This serializer assumes that the user's application needs to serialize a Java Bean to JSON data using Jackson. In addition to standard serialization of the bean, this implementation can also optionally validate it against a JSON schema.- Author:
- eric.wittmann@gmail.com, Ales Justin, Fabian Martinez, Carles Arnal
-
-
Field Summary
-
Fields inherited from class io.apicurio.registry.serde.AbstractKafkaSerDe
headersHandler, idHandler, key, log, MAGIC_BYTE
-
Fields inherited from class io.apicurio.registry.serde.SchemaResolverConfigurer
schemaResolver
-
-
Constructor Summary
Constructors Constructor Description JsonSchemaKafkaSerializer()JsonSchemaKafkaSerializer(io.apicurio.registry.resolver.SchemaResolver<JsonSchema,T> schemaResolver)JsonSchemaKafkaSerializer(io.apicurio.registry.rest.client.RegistryClient client)JsonSchemaKafkaSerializer(io.apicurio.registry.rest.client.RegistryClient client, io.apicurio.registry.resolver.strategy.ArtifactReferenceResolverStrategy<JsonSchema,T> artifactResolverStrategy, io.apicurio.registry.resolver.SchemaResolver<JsonSchema,T> schemaResolver)JsonSchemaKafkaSerializer(io.apicurio.registry.rest.client.RegistryClient client, Boolean validationEnabled)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconfigure(Map<String,?> configs, boolean isKey)booleanisValidationEnabled()io.apicurio.registry.resolver.SchemaParser<JsonSchema,T>schemaParser()protected voidserializeData(io.apicurio.registry.resolver.ParsedSchema<JsonSchema> schema, T data, OutputStream out)protected voidserializeData(org.apache.kafka.common.header.Headers headers, io.apicurio.registry.resolver.ParsedSchema<JsonSchema> schema, T data, OutputStream out)voidsetObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)voidsetValidationEnabled(Boolean validationEnabled)-
Methods inherited from class io.apicurio.registry.serde.AbstractKafkaSerializer
close, serialize, serialize
-
Methods inherited from class io.apicurio.registry.serde.AbstractKafkaSerDe
asLegacyId, configure, getByteBuffer, getIdHandler, isKey, reset, setHeadersHandler, setIdHandler
-
Methods inherited from class io.apicurio.registry.serde.SchemaResolverConfigurer
configure, getSchemaResolver, setSchemaResolver
-
-
-
-
Constructor Detail
-
JsonSchemaKafkaSerializer
public JsonSchemaKafkaSerializer()
-
JsonSchemaKafkaSerializer
public JsonSchemaKafkaSerializer(io.apicurio.registry.rest.client.RegistryClient client, io.apicurio.registry.resolver.strategy.ArtifactReferenceResolverStrategy<JsonSchema,T> artifactResolverStrategy, io.apicurio.registry.resolver.SchemaResolver<JsonSchema,T> schemaResolver)
-
JsonSchemaKafkaSerializer
public JsonSchemaKafkaSerializer(io.apicurio.registry.rest.client.RegistryClient client)
-
JsonSchemaKafkaSerializer
public JsonSchemaKafkaSerializer(io.apicurio.registry.resolver.SchemaResolver<JsonSchema,T> schemaResolver)
-
JsonSchemaKafkaSerializer
public JsonSchemaKafkaSerializer(io.apicurio.registry.rest.client.RegistryClient client, Boolean validationEnabled)
-
-
Method Detail
-
configure
public void configure(Map<String,?> configs, boolean isKey)
- Specified by:
configurein interfaceorg.apache.kafka.common.serialization.Serializer<T>- Overrides:
configurein classAbstractKafkaSerializer<JsonSchema,T>- See Also:
AbstractKafkaSerializer.configure(java.util.Map, boolean)
-
isValidationEnabled
public boolean isValidationEnabled()
-
setObjectMapper
public void setObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
setValidationEnabled
public void setValidationEnabled(Boolean validationEnabled)
- Parameters:
validationEnabled- the validationEnabled to set
-
schemaParser
public io.apicurio.registry.resolver.SchemaParser<JsonSchema,T> schemaParser()
- Specified by:
schemaParserin classAbstractKafkaSerDe<JsonSchema,T>- See Also:
AbstractKafkaSerDe.schemaParser()
-
serializeData
protected void serializeData(io.apicurio.registry.resolver.ParsedSchema<JsonSchema> schema, T data, OutputStream out) throws IOException
- Specified by:
serializeDatain classAbstractKafkaSerializer<JsonSchema,T>- Throws:
IOException- See Also:
io.apicurio.registry.serde.AbstractKafkaSerializer#serializeData(io.apicurio.registry.serde.ParsedSchema, java.lang.Object, java.io.OutputStream)
-
serializeData
protected void serializeData(org.apache.kafka.common.header.Headers headers, io.apicurio.registry.resolver.ParsedSchema<JsonSchema> schema, T data, OutputStream out) throws IOException- Specified by:
serializeDatain classAbstractKafkaSerializer<JsonSchema,T>- Throws:
IOException- See Also:
io.apicurio.registry.serde.AbstractKafkaSerializer#serializeData(org.apache.kafka.common.header.Headers, io.apicurio.registry.serde.ParsedSchema, java.lang.Object, java.io.OutputStream)
-
-