Class MappingPdxSerializer
java.lang.Object
org.springframework.data.gemfire.mapping.MappingPdxSerializer
- All Implemented Interfaces:
PdxSerializer
,Aware
,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
- Author:
- Oliver Gierke, David Turanski, John Blum
- See Also:
-
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, ConversionService conversionService) Constructs a new instance ofMappingPdxSerializer
initialized with the givenGemfireMappingContext
andConversionService
. -
Method Summary
Modifier and TypeMethodDescriptionstatic MappingPdxSerializer
create
(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, ConversionService conversionService) Factory method used to construct a new instance ofMappingPdxSerializer
initialized with the givenmapping context
andconversion service
.protected ConversionService
Returns a reference to the configuredConversionService
used to convert data store types to application domain object types.protected Map<?,
PdxSerializer> Returns amapping
of applicationdomain types
to customPDX serializers
used to customize the serialization for specific applicationdomain types
.protected 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 PdxSerializer
resolveCustomPdxSerializer
(PersistentProperty<?> property) protected EntityInstantiator
Looks up and returns a registeredEntityInstantiator
used to construct and initialize an instance of an object defined by the givenPersistentEntity
(meta-data).void
setApplicationContext
(ApplicationContext applicationContext) Configures a reference to the SpringApplicationContext
.void
setCustomPdxSerializers
(Map<?, PdxSerializer> customPdxSerializers) Configures customPDX serializers
used to customize the serialization for specific applicationdomain types
.void
setEntityInstantiators
(Map<Class<?>, EntityInstantiator> gemfireInstantiators) Configures theEntityInstantiators
used to create the instances read by thisPdxSerializer
.void
setEntityInstantiators
(EntityInstantiators entityInstantiators) Configures theEntityInstantiators
used to create the instances read by thisPdxSerializer
.void
setExcludeTypeFilters
(Predicate<Class<?>> excludeTypeFilters) 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, 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
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 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:
-
setApplicationContext
Configures a reference to the SpringApplicationContext
.- Specified by:
setApplicationContext
in interfaceApplicationContextAware
- Parameters:
applicationContext
- reference to the SpringApplicationContext
.- Throws:
BeansException
- See Also:
-
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:
-
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:
-
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:
-
setEntityInstantiators
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:
-
setEntityInstantiators
Configures theEntityInstantiators
used to create the instances read by thisPdxSerializer
.- Parameters:
gemfireInstantiators
- mapping oftypes
toEntityInstantiator
objects; must not be null.- See Also:
-
getEntityInstantiators
Returns the configuredEntityInstantiators
handling instantiation for GemFire persistent entities.- Returns:
- the configured
EntityInstantiators
handling instantiation for GemFire persistent entities. - See Also:
-
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.- Parameters:
entityType
-Class
type of the actual persistent entity, application domain objectClass
.- Returns:
- the
PersistentEntity
meta-data for the given entityClass
type. - See Also:
-
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 interfacePdxSerializer
- 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 interfacePdxSerializer
- 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 PdxSerializer resolveCustomPdxSerializer(@NonNull PersistentProperty<?> property) - 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:
-
resolveEntityInstantiator
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:
-