Package org.nuxeo.runtime.avro
Class AvroServiceImpl
- java.lang.Object
-
- org.nuxeo.runtime.avro.AvroServiceImpl
-
- All Implemented Interfaces:
AvroService
public class AvroServiceImpl extends Object implements AvroService
- Since:
- 10.2
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<Class<?>,Class<AvroSchemaFactory<?>>>
factories
protected Map<Class<?>,AvroMapper<?,?>>
mappers
protected List<AvroReplacementDescriptor>
replacements
protected AvroSchemaStore
schemaStore
-
Constructor Summary
Constructors Constructor Description AvroServiceImpl(Collection<AvroReplacementDescriptor> replacements, Map<Class<?>,Class<AvroSchemaFactory<?>>> factories)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected AvroSchemaFactoryContext
createContext()
<D> org.apache.avro.Schema
createSchema(D input)
Creates the Avro schema from an object.
An AvroSchemaFactory handling the object class has to be implemented and registered to the AvroComponent..String
decodeName(String input)
Decodes a valid Avro name to its actual value.String
encodeName(String input)
Encodes a name for it to be eligible to Avro limitations (alphanumeric and _).
By default Nuxeo can encode - and :
Other replacements can be registered to the AvroComponent.<D,M>
DfromAvro(org.apache.avro.Schema schema, Class<D> clazz, M input)
Map an Avro data to an instance of the given class.
An AvroMapper handling the given class has to be implemented and registered to the AvroComponent..protected <D,M>
AvroMapper<D,M>getMapper(Class<D> clazz)
AvroSchemaStore
getSchemaStore()
Gets the Schema storevoid
setMappers(Map<Class<?>,AvroMapper<?,?>> mappers)
<D,M>
MtoAvro(org.apache.avro.Schema schema, D input)
Map an object to an Avro data.
An AvroMapper handling the given class has to be implemented and registered.
-
-
-
Field Detail
-
factories
protected final Map<Class<?>,Class<AvroSchemaFactory<?>>> factories
-
replacements
protected final List<AvroReplacementDescriptor> replacements
-
schemaStore
protected final AvroSchemaStore schemaStore
-
mappers
protected Map<Class<?>,AvroMapper<?,?>> mappers
-
-
Constructor Detail
-
AvroServiceImpl
public AvroServiceImpl(Collection<AvroReplacementDescriptor> replacements, Map<Class<?>,Class<AvroSchemaFactory<?>>> factories)
-
-
Method Detail
-
getSchemaStore
public AvroSchemaStore getSchemaStore()
Description copied from interface:AvroService
Gets the Schema store- Specified by:
getSchemaStore
in interfaceAvroService
-
createSchema
public <D> org.apache.avro.Schema createSchema(D input)
Description copied from interface:AvroService
Creates the Avro schema from an object.
An AvroSchemaFactory handling the object class has to be implemented and registered to the AvroComponent..- Specified by:
createSchema
in interfaceAvroService
- Parameters:
input
- any object- Returns:
- the Avro schema
-
decodeName
public String decodeName(String input)
Description copied from interface:AvroService
Decodes a valid Avro name to its actual value.- Specified by:
decodeName
in interfaceAvroService
- Parameters:
input
- the name to decode- Returns:
- the decoded name
-
encodeName
public String encodeName(String input)
Description copied from interface:AvroService
Encodes a name for it to be eligible to Avro limitations (alphanumeric and _).
By default Nuxeo can encode - and :
Other replacements can be registered to the AvroComponent.- Specified by:
encodeName
in interfaceAvroService
- Parameters:
input
- the name to encode- Returns:
- the encoded name
-
fromAvro
public <D,M> D fromAvro(org.apache.avro.Schema schema, Class<D> clazz, M input)
Description copied from interface:AvroService
Map an Avro data to an instance of the given class.
An AvroMapper handling the given class has to be implemented and registered to the AvroComponent..- Specified by:
fromAvro
in interfaceAvroService
- Parameters:
schema
- the Avro schemaclazz
- the class to map the Avro object toinput
- the Avro data- Returns:
- an instance of the given class
-
setMappers
public void setMappers(Map<Class<?>,AvroMapper<?,?>> mappers)
-
toAvro
public <D,M> M toAvro(org.apache.avro.Schema schema, D input)
Description copied from interface:AvroService
Map an object to an Avro data.
An AvroMapper handling the given class has to be implemented and registered.- Specified by:
toAvro
in interfaceAvroService
- Parameters:
schema
- the Avro schemainput
- the object to map to an Avro data- Returns:
- the Avro data
-
createContext
protected AvroSchemaFactoryContext createContext()
-
getMapper
protected <D,M> AvroMapper<D,M> getMapper(Class<D> clazz)
-
-