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<?>>>factoriesprotected Map<Class<?>,AvroMapper<?,?>>mappersprotected List<AvroReplacementDescriptor>replacementsprotected AvroSchemaStoreschemaStore 
- 
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 AvroSchemaFactoryContextcreateContext()<D> org.apache.avro.SchemacreateSchema(D input)Creates the Avro schema from an object.
An AvroSchemaFactory handling the object class has to be implemented and registered to the AvroComponent..StringdecodeName(String input)Decodes a valid Avro name to its actual value.StringencodeName(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)AvroSchemaStoregetSchemaStore()Gets the Schema storevoidsetMappers(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:AvroServiceGets the Schema store- Specified by:
 getSchemaStorein interfaceAvroService
 
- 
createSchema
public <D> org.apache.avro.Schema createSchema(D input)
Description copied from interface:AvroServiceCreates the Avro schema from an object.
An AvroSchemaFactory handling the object class has to be implemented and registered to the AvroComponent..- Specified by:
 createSchemain interfaceAvroService- Parameters:
 input- any object- Returns:
 - the Avro schema
 
 
- 
decodeName
public String decodeName(String input)
Description copied from interface:AvroServiceDecodes a valid Avro name to its actual value.- Specified by:
 decodeNamein interfaceAvroService- Parameters:
 input- the name to decode- Returns:
 - the decoded name
 
 
- 
encodeName
public String encodeName(String input)
Description copied from interface:AvroServiceEncodes 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:
 encodeNamein 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:AvroServiceMap 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:
 fromAvroin 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:AvroServiceMap an object to an Avro data.
An AvroMapper handling the given class has to be implemented and registered.- Specified by:
 toAvroin 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)
 
 - 
 
 -