-
Notifications
You must be signed in to change notification settings - Fork 92
JSON Serialization
Internally, Achilles stores data in JSON format using the Jackson Mapper library. JSON serialization is way faster than the old plain Object serialization since only data are serialized, not class structure.
By default, Achilles sets up an internal Object Mapper with the following feature config:
- SerializationInclusion = JsonInclude.Include.NON_NULL
- DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES = false
- AnnotationIntrospector pair : primary = JacksonAnnotationIntrospector, secondary = JaxbAnnotationIntrospector
Jackson will serialize all your entities even if they do not have any JSON annotations. You can also use JAXB annotations.
## Custom Object Mapper
It is possible to inject a pre-configured Jackson Object Mapper as configuration parameter to bootstrap the PersistenceManagerFactory
class using the OBJECT_MAPPER parameter.
Map<ConfigurationParameters,Object> configMap = new HashMap<>();
configMap.put(OBJECT_MAPPER, preConfiguredObjectMapper);
...
PersistenceManagerFactory pmf = PersistenceManagerFactoryBuilder.build(configMap);
## Custom Object Mapper Factory
Last but not least, it is possible to further custom JSON serialization using the ObjectMapperFactory
interface using the OBJECT_MAPPER_FACTORY parameter:
public interface ObjectMapperFactory
{
public <T> ObjectMapper getMapper(Class<T> type);
}
Map<ConfigurationParameters,Object> configMap = new HashMap<>();
configMap.put(OBJECT_MAPPER, customObjectMapperFactoryImpl);
...
PersistenceManagerFactory pmf = PersistenceManagerFactoryBuilder.build(configMap);
When both OBJECT_MAPPER_FACTORY and OBJECT_MAPPER params are provided for configuration, Achilles will ignore the OBJECT_MAPPER param and only use the OBJECT_MAPPER_FACTORY one
-
Bootstraping Achilles at runtime
- Runtime Configuration Parameters
-
Manager
-
Consistency Level
-
Cassandra Options at runtime
-
Lightweight Transaction (LWT)
-
JSON Serialization
-
Interceptors
-
Bean Validation (JSR-303)