Class MappingPdxSerializer
java.lang.Object
org.springframework.data.gemfire.mapping.MappingPdxSerializer
- All Implemented Interfaces:
org.apache.geode.pdx.PdxSerializer
,org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
public class MappingPdxSerializer
extends Object
implements org.apache.geode.pdx.PdxSerializer, org.springframework.context.ApplicationContextAware
PdxSerializer
implementation using the Spring Data for Apache Geode GemfireMappingContext
to read (deserialize) and write (serialize) entities from and to PDX.- Since:
- 1.2.0
- See Also:
-
PdxReader
PdxSerializer
PdxWriter
ApplicationContext
ApplicationContextAware
ConversionService
Filter
PersistentEntity
PersistentProperty
PersistentPropertyAccessor
PropertyHandler
ConvertingPropertyAccessor
EntityInstantiator
EntityInstantiators
PersistentEntityParameterValueProvider
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static enum
static enum
-
Field Summary
-
Constructor Summary
ConstructorDescriptionConstructs a new instance ofMappingPdxSerializer
using a defaultGemfireMappingContext
andDefaultConversionService
.MappingPdxSerializer
(GemfireMappingContext mappingContext, org.springframework.core.convert.ConversionService conversionService) Constructs a new instance ofMappingPdxSerializer
initialized with the givenGemfireMappingContext
andConversionService
. -
Method Summary
Modifier and TypeMethodDescriptionstatic MappingPdxSerializer
create
(org.springframework.core.convert.ConversionService conversionService) Factory method used to construct a new instance ofMappingPdxSerializer
initialized with the givenConversionService
and a providedGemfireMappingContext
.static MappingPdxSerializer
create
(GemfireMappingContext mappingContext) Factory method used to construct a new instance ofMappingPdxSerializer
initialized with the givenmapping context
supplying entity mapping meta-data, using a provided, defaultConversionService
.static MappingPdxSerializer
create
(GemfireMappingContext mappingContext, org.springframework.core.convert.ConversionService conversionService) Factory method used to construct a new instance ofMappingPdxSerializer
initialized with the givenmapping context
andconversion service
.protected org.springframework.core.convert.ConversionService
Returns a reference to the configuredConversionService
used to convert data store types to application domain object types.protected Map<?,
org.apache.geode.pdx.PdxSerializer> Returns amapping
of applicationdomain types
to customPDX serializers
used to customize the serialization for specific applicationdomain types
.protected org.springframework.data.mapping.model.EntityInstantiators
Returns the configuredEntityInstantiators
handling instantiation for GemFire persistent entities.protected org.slf4j.Logger
Returns a reference to the configuredLogger
used to logmessages
about the functions of thisPdxSerializer
.protected GemfireMappingContext
Returns a reference to the configuredmapping context
used to handling mapping logic between GemFire persistent entities and application domain objecttypes
.protected GemfirePersistentEntity<?>
getPersistentEntity
(Class<?> entityType) Looks up and returns thePersistentEntity
meta-data for the given entityClass
type.protected GemfirePersistentEntity<?>
getPersistentEntity
(Object entity) Looks up and returns thePersistentEntity
meta-data for the given entity object.static MappingPdxSerializer
Factory method used to construct a new instance ofMappingPdxSerializer
initialized with a providedGemfireMappingContext
and defaultConversionService
.void
register
(MappingPdxSerializer.PdxSerializerResolver pdxSerializerResolver) Registers the givenMappingPdxSerializer.PdxSerializerResolver
, which will be used to resolve a customPdxSerializer
for a entity property.protected org.apache.geode.pdx.PdxSerializer
resolveCustomPdxSerializer
(org.springframework.data.mapping.PersistentProperty<?> property) Returns a customPdxSerializer
for the givenPersistentEntity
PersistentProperty
.protected org.springframework.data.mapping.model.EntityInstantiator
resolveEntityInstantiator
(org.springframework.data.mapping.PersistentEntity entity) Looks up and returns a registeredEntityInstantiator
used to construct and initialize an instance of an object defined by the givenPersistentEntity
(meta-data).void
setApplicationContext
(org.springframework.context.ApplicationContext applicationContext) Configures a reference to the SpringApplicationContext
.void
setCustomPdxSerializers
(Map<?, org.apache.geode.pdx.PdxSerializer> customPdxSerializers) Configures customPDX serializers
used to customize the serialization for specific applicationdomain types
.void
setEntityInstantiators
(Map<Class<?>, org.springframework.data.mapping.model.EntityInstantiator> gemfireInstantiators) Configures theEntityInstantiators
used to create the instances read by thisPdxSerializer
.void
setEntityInstantiators
(org.springframework.data.mapping.model.EntityInstantiators entityInstantiators) Configures theEntityInstantiators
used to create the instances read by thisPdxSerializer
.void
setExcludeTypeFilters
(Predicate<Class<?>> excludeTypeFilters) Sets thetype filters
used to exclude (a.k.a.void
setIncludeTypeFilters
(Predicate<Class<?>> includeTypeFilters) boolean
Serialize (write) the givenObject
to PDX.
-
Field Details
-
JAVA_PACKAGE_NAME
- See Also:
-
COM_GEMSTONE_GEMFIRE_PACKAGE_NAME
- See Also:
-
ORG_APACHE_GEODE_PACKAGE_NAME
- See Also:
-
ORG_SPRINGFRAMEWORK_PACKAGE_NAME
- See Also:
-
-
Constructor Details
-
MappingPdxSerializer
public MappingPdxSerializer()Constructs a new instance ofMappingPdxSerializer
using a defaultGemfireMappingContext
andDefaultConversionService
.- See Also:
-
newConversionService()
newMappingContext()
DefaultConversionService
GemfireMappingContext
-
MappingPdxSerializer
public MappingPdxSerializer(GemfireMappingContext mappingContext, org.springframework.core.convert.ConversionService conversionService) Constructs a new instance ofMappingPdxSerializer
initialized with the givenGemfireMappingContext
andConversionService
.- Parameters:
mappingContext
-GemfireMappingContext
used by theMappingPdxSerializer
to map between application domain object types and PDX serialized bytes based on the entity mapping meta-data.conversionService
-ConversionService
used by theMappingPdxSerializer
to convert PDX serialized data to application object property types.- Throws:
IllegalArgumentException
- if either theGemfireMappingContext
or theConversionService
is null.
-
-
Method Details
-
newMappingPdxSerializer
Factory method used to construct a new instance ofMappingPdxSerializer
initialized with a providedGemfireMappingContext
and defaultConversionService
.- Returns:
- a new instance of
MappingPdxSerializer
. - See Also:
-
create(GemfireMappingContext, ConversionService)
newMappingContext()
newConversionService()
-
create
@NonNull public static MappingPdxSerializer create(@Nullable org.springframework.core.convert.ConversionService conversionService) Factory method used to construct a new instance ofMappingPdxSerializer
initialized with the givenConversionService
and a providedGemfireMappingContext
.- Parameters:
conversionService
-ConversionService
used to convert persistent values to entity properties.- Returns:
- a new instance of
MappingPdxSerializer
initialized with the givenConversionService
. - See Also:
-
ConversionService
create(GemfireMappingContext, ConversionService)
newMappingContext()
-
create
Factory method used to construct a new instance ofMappingPdxSerializer
initialized with the givenmapping context
supplying entity mapping meta-data, using a provided, defaultConversionService
.- Parameters:
mappingContext
-GemfireMappingContext
used to supply entity mapping meta-data.- Returns:
- a new instance of
MappingPdxSerializer
initialized with the givenmapping context
. - See Also:
-
GemfireMappingContext
create(GemfireMappingContext, ConversionService)
newConversionService()
-
create
@NonNull public static MappingPdxSerializer create(@Nullable GemfireMappingContext mappingContext, @Nullable org.springframework.core.convert.ConversionService conversionService) Factory method used to construct a new instance ofMappingPdxSerializer
initialized with the givenmapping context
andconversion service
. If either themapping context
or theconversion service
are null, then this factory method will provide default instances for each.- Parameters:
mappingContext
-GemfireMappingContext
used to map between application domain model object types and PDX serialized bytes based on the entity's mapping meta-data.conversionService
-ConversionService
used to convert persistent values to entity properties.- Returns:
- an initialized instance of the
MappingPdxSerializer
. - See Also:
-
ConversionService
MappingPdxSerializer
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException Configures a reference to the SpringApplicationContext
.- Specified by:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
- Parameters:
applicationContext
- reference to the SpringApplicationContext
.- Throws:
org.springframework.beans.BeansException
- See Also:
-
ApplicationContext
-
getConversionService
@NonNull protected org.springframework.core.convert.ConversionService getConversionService()Returns a reference to the configuredConversionService
used to convert data store types to application domain object types.- Returns:
- a reference to the configured
ConversionService
. - See Also:
-
ConversionService
-
setCustomPdxSerializers
Configures customPDX serializers
used to customize the serialization for specific applicationdomain types
.- Parameters:
customPdxSerializers
-mapping
containing customPDX serializers
used to customize the serialization of specific applicationdomain types
.- Throws:
IllegalArgumentException
- if thecustom PDX serializer mapping
is null.- See Also:
-
PdxSerializer
Map
-
getCustomPdxSerializers
Returns amapping
of applicationdomain types
to customPDX serializers
used to customize the serialization for specific applicationdomain types
.- Returns:
- a
mapping
of applicationdomain types
to customPDX serializers
. - See Also:
-
PdxSerializer
Map
-
setEntityInstantiators
public void setEntityInstantiators(@NonNull org.springframework.data.mapping.model.EntityInstantiators entityInstantiators) Configures theEntityInstantiators
used to create the instances read by thisPdxSerializer
.- Parameters:
entityInstantiators
-EntityInstantiators
used to create the instances read by thisPdxSerializer
; must not be null.- See Also:
-
EntityInstantiator
-
setEntityInstantiators
public void setEntityInstantiators(@NonNull Map<Class<?>, org.springframework.data.mapping.model.EntityInstantiator> gemfireInstantiators) Configures theEntityInstantiators
used to create the instances read by thisPdxSerializer
. -
getEntityInstantiators
protected org.springframework.data.mapping.model.EntityInstantiators getEntityInstantiators()Returns the configuredEntityInstantiators
handling instantiation for GemFire persistent entities.- Returns:
- the configured
EntityInstantiators
handling instantiation for GemFire persistent entities. - See Also:
-
EntityInstantiators
-
getLogger
@NonNull protected org.slf4j.Logger getLogger()Returns a reference to the configuredLogger
used to logmessages
about the functions of thisPdxSerializer
.- Returns:
- a reference to the configured
Logger
. - See Also:
-
Logger
-
getMappingContext
Returns a reference to the configuredmapping context
used to handling mapping logic between GemFire persistent entities and application domain objecttypes
.- Returns:
- a reference to the configured
mapping context
for Pivotal GemFire. - See Also:
-
getPersistentEntity
Looks up and returns thePersistentEntity
meta-data for the given entity object.- Parameters:
entity
- actual persistent entity, application domain object.- Returns:
- the
PersistentEntity
meta-data for the given entity object. - See Also:
-
getPersistentEntity
Looks up and returns thePersistentEntity
meta-data for the given entityClass
type. -
setExcludeTypeFilters
Sets thetype filters
used to exclude (a.k.a. filter)types
serializable by thisPDX serializer
. This operation is null-safe and rather than overriding the existingexcluded type filters
, this set operation combines the givenexclude type filters
with the exitingexcluded type filters
joined by and.- Parameters:
excludeTypeFilters
-type filters
used to exclude/filtertypes
serializable by thisPDX serializer
.- See Also:
-
setIncludeTypeFilters
Sets thetype filters
used to includetypes
serializable by thisPDX serializer
. This operation is null-safe and rather than overriding the existingincluded type filters
, this set operation combines the giveninclude type filters
with the exitingincluded type filters
joined by or.- Parameters:
includeTypeFilters
-type filters
used to includetypes
serializable by thisPDX serializer
.- See Also:
-
getTypeFilters
- Returns:
- the resolved
type filter
. - See Also:
-
register
Registers the givenMappingPdxSerializer.PdxSerializerResolver
, which will be used to resolve a customPdxSerializer
for a entity property. The strategy, or criteria used to resolve the customPdxSerializer
is up to the individual resolve and can be based on things like the property type, or fully-qualified property name, etc.- Parameters:
pdxSerializerResolver
-MappingPdxSerializer.PdxSerializerResolver
used to resolve a customPdxSerializer
for a entity property.
-
fromData
- Specified by:
fromData
in interfaceorg.apache.geode.pdx.PdxSerializer
- Parameters:
type
- desiredClass
type of theObject
; must not be null.pdxReader
-PdxReader
used to deserialize the PDX bytes back into anObject
of the desiredClass
type; must not be null.- Returns:
- an
Object
ofClass
type deserialized from PDX or null if anObject
ofClass
type cannot be deserialized from PDX. - See Also:
-
PdxReader
doFromData(Class, PdxReader)
getTypeFilters()
Class
Object
-
toData
Serialize (write) the givenObject
to PDX.- Specified by:
toData
in interfaceorg.apache.geode.pdx.PdxSerializer
- Parameters:
value
-Object
to serialize.pdxWriter
-PdxWriter
used to serialize the givenObject
to PDX.- Returns:
- a boolean value indicating whether this
PdxSerializer
was able to serialize the givenObject
to PDX. - See Also:
-
PdxWriter
doToData(Object, PdxWriter)
getTypeFilters()
Object
-
resolveCustomPdxSerializer
@Nullable protected org.apache.geode.pdx.PdxSerializer resolveCustomPdxSerializer(@NonNull org.springframework.data.mapping.PersistentProperty<?> property) Returns a customPdxSerializer
for the givenPersistentEntity
PersistentProperty
.- Parameters:
property
-PersistentProperty
of the entity used to resolve a customPdxSerializer
.- Returns:
- a custom
PdxSerializer
for the givenPersistentEntity
PersistentProperty
, or null if no customPdxSerializer
could be found. - See Also:
-
PersistentProperty
PdxSerializer
getCustomPdxSerializers()
-
resolveEntityInstantiator
protected org.springframework.data.mapping.model.EntityInstantiator resolveEntityInstantiator(@NonNull org.springframework.data.mapping.PersistentEntity entity) Looks up and returns a registeredEntityInstantiator
used to construct and initialize an instance of an object defined by the givenPersistentEntity
(meta-data).- Parameters:
entity
-PersistentEntity
object used to lookup a custom, registeredEntityInstantiator
for the entity.- Returns:
- an
EntityInstantiator
for the givenPersistentEntity
. - See Also:
-
EntityInstantiator
PersistentEntity
-