Search code examples
cachingcloud-foundrygemfirespring-data-gemfire

Can we convert fields to/from GemFire PdxSerializer using annotations or Java Reflection?


Currently we are using GemFire for caching. We are in our initial phase of integrating it.

While we are working on integrating GemFire using the Spring Data GemFire libraries, and using GemFire's PdxSerializer, too, I am wondering if there is a way to convert fields to/from PDXReader/PDXWriter using basic annotations and Java Reflection.

We are using Sprint Boot's 2.0.3.RELEASE JARs.

Note: I have looked at the below link:

https://gemfire.docs.pivotal.io/95/geode/developing/data_serialization/auto_serialization.html

I am more curious how to use a non-XML way of doing this.


Solution

  • Have a look at the following:

    1. SDG's o.s.d.g.mapping.MappingPdxSerializer as described in the documentation.

    2. Then read how to configure it.

    3. If you are using Spring Boot for Pivotal GemFire, then PDX is auto-configured automatically, by default, for you and you do not need to explicitly declare SDG's @EnablePdx annotation.

    NOTE: SDG's MappingPdxSerializer, when configured and registered with Pivotal GemFire, automatically de/serializes your application domain object types without any special config, like you have to do when using GemFire's own ReflectionBasedAutoSerializer and clumsy REGEX to identify your types properly, blah! SDG's MappingPdxSerializer is much more robust, using first-class filters to express exclusions and even inclusions (which can override the default exclusions, that is any class types in java.*, com.gemstone.gemfire.*, org.apache.geode.* or org.springframework.*, by default).

    Anyway...

    Take 2 pills and call me in the morning - the "doc", ;-)