public class MappingPdxSerializer extends Object implements org.apache.geode.pdx.PdxSerializer, ApplicationContextAware
PdxSerializer implementation using the SDG GemfireMappingContext to read and write entities
from/to Pivotal GemFire PDX bytes.PdxReader,
PdxSerializer,
PdxWriter,
ApplicationContext,
ApplicationContextAware,
ConversionService,
EntityInstantiator,
EntityInstantiators,
PersistentEntity,
PersistentProperty,
PersistentPropertyAccessor,
ConvertingPropertyAccessor,
PersistentEntityParameterValueProvider| Modifier and Type | Class and Description |
|---|---|
static class |
MappingPdxSerializer.TypeFilters |
| Modifier and Type | Field and Description |
|---|---|
protected static String |
COM_GEMSTONE_GEMFIRE_PACKAGE_NAME |
protected static String |
ORG_APACHE_GEODE_PACKAGE_NAME |
| Constructor and Description |
|---|
MappingPdxSerializer()
Constructs a new instance of
MappingPdxSerializer using a default GemfireMappingContext
and DefaultConversionService. |
MappingPdxSerializer(GemfireMappingContext mappingContext,
ConversionService conversionService)
Constructs a new instance of
MappingPdxSerializer initialized with the given
GemfireMappingContext and ConversionService. |
| Modifier and Type | Method and Description |
|---|---|
static MappingPdxSerializer |
create(ConversionService conversionService)
Factory method used to construct a new instance of
MappingPdxSerializer initialized with
the given ConversionService and a provided GemfireMappingContext. |
static MappingPdxSerializer |
create(GemfireMappingContext mappingContext)
Factory method used to construct a new instance of
MappingPdxSerializer initialized with
the given mapping context supplying entity mapping meta-data,
using a provided, default ConversionService. |
static MappingPdxSerializer |
create(GemfireMappingContext mappingContext,
ConversionService conversionService)
Factory method used to construct a new instance of
MappingPdxSerializer initialized with
the given mapping context and conversion service. |
Object |
fromData(Class<?> type,
org.apache.geode.pdx.PdxReader reader) |
protected ConversionService |
getConversionService()
Returns a reference to the configured
ConversionService used to convert data store types
to application domain object types. |
protected org.apache.geode.pdx.PdxSerializer |
getCustomPdxSerializer(PersistentProperty<?> property)
Returns a custom PDX serializer for the given
entity persistent property. |
protected Map<?,org.apache.geode.pdx.PdxSerializer> |
getCustomPdxSerializers()
Returns a
mapping of application domain types to custom
PDX serializers used to customize the serialization
for specific application domain types. |
protected org.apache.geode.pdx.PdxSerializer |
getCustomSerializer(Class<?> type)
Deprecated.
please use
getCustomPdxSerializer(PersistentProperty) instead. |
protected Map<Class<?>,org.apache.geode.pdx.PdxSerializer> |
getCustomSerializers()
Deprecated.
please use
getCustomPdxSerializers() instead. |
protected EntityInstantiators |
getGemfireInstantiators()
Returns the configured
EntityInstantiators handling instantiation for Pivotal GemFire persistent entities. |
protected EntityInstantiator |
getInstantiatorFor(PersistentEntity entity)
Looks up and returns an EntityInstantiator to construct and initialize an instance of the object defined
by the given PersistentEntity (meta-data).
|
protected org.slf4j.Logger |
getLogger()
Returns a reference to the configured
Logger used to log messages
about the functions of this PdxSerializer. |
protected GemfireMappingContext |
getMappingContext()
Returns a reference to the configured
mapping context used to handling mapping
logic between Pivotal GemFire persistent entities and application domain object types. |
protected GemfirePersistentEntity<?> |
getPersistentEntity(Class<?> entityType)
Looks up and returns the
PersistentEntity meta-data for the given entity Class type. |
protected GemfirePersistentEntity<?> |
getPersistentEntity(Object entity)
Looks up and returns the
PersistentEntity meta-data for the given entity object. |
protected Predicate<Class<?>> |
getTypeFilters()
|
static MappingPdxSerializer |
newMappingPdxSerializer()
Factory method used to construct a new instance of
MappingPdxSerializer initialized with
a provided GemfireMappingContext and default ConversionService. |
void |
setApplicationContext(ApplicationContext applicationContext)
Configures a reference to the Spring
ApplicationContext. |
void |
setCustomPdxSerializers(Map<?,org.apache.geode.pdx.PdxSerializer> customPdxSerializers)
Configures custom
PDX serializers used to customize the serialization for specific
application domain types. |
void |
setCustomSerializers(Map<Class<?>,org.apache.geode.pdx.PdxSerializer> customSerializers)
Deprecated.
please use (
setCustomPdxSerializers(Map) instead. |
void |
setGemfireInstantiators(EntityInstantiators entityInstantiators)
Configures the
EntityInstantiators used to create the instances
read by this PdxSerializer. |
void |
setGemfireInstantiators(Map<Class<?>,EntityInstantiator> gemfireInstantiators)
Configures the
EntityInstantiators used to create the instances
read by this PdxSerializer. |
void |
setTypeFilters(Predicate<Class<?>> typeFilters)
|
boolean |
toData(Object value,
org.apache.geode.pdx.PdxWriter writer) |
protected static final String COM_GEMSTONE_GEMFIRE_PACKAGE_NAME
protected static final String ORG_APACHE_GEODE_PACKAGE_NAME
public MappingPdxSerializer()
MappingPdxSerializer using a default GemfireMappingContext
and DefaultConversionService.public MappingPdxSerializer(GemfireMappingContext mappingContext, ConversionService conversionService)
MappingPdxSerializer initialized with the given
GemfireMappingContext and ConversionService.mappingContext - GemfireMappingContext used by the MappingPdxSerializer to map
between application domain object types and PDX serialized bytes based on the entity mapping meta-data.conversionService - ConversionService used by the MappingPdxSerializer to convert
PDX serialized data to application object property types.IllegalArgumentException - if either the GemfireMappingContext or the ConversionService
is null.public static MappingPdxSerializer newMappingPdxSerializer()
MappingPdxSerializer initialized with
a provided GemfireMappingContext and default ConversionService.MappingPdxSerializer.create(GemfireMappingContext, ConversionService),
newMappingContext(),
newConversionService()public static MappingPdxSerializer create(@Nullable ConversionService conversionService)
MappingPdxSerializer initialized with
the given ConversionService and a provided GemfireMappingContext.conversionService - ConversionService used to convert persistent values to entity properties.MappingPdxSerializer initialized with the given ConversionService.ConversionService,
create(GemfireMappingContext, ConversionService),
newMappingContext()public static MappingPdxSerializer create(@Nullable GemfireMappingContext mappingContext)
MappingPdxSerializer initialized with
the given mapping context supplying entity mapping meta-data,
using a provided, default ConversionService.mappingContext - GemfireMappingContext used to supply entity mapping meta-data.MappingPdxSerializer initialized with
the given mapping context.GemfireMappingContext,
create(GemfireMappingContext, ConversionService),
newConversionService()public static MappingPdxSerializer create(@Nullable GemfireMappingContext mappingContext, @Nullable ConversionService conversionService)
MappingPdxSerializer initialized with
the given mapping context and conversion service.
If either the mapping context or the conversion service
are null, then this factory method will provide default instances for each.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.MappingPdxSerializer.ConversionService,
MappingPdxSerializerpublic void setApplicationContext(ApplicationContext applicationContext) throws BeansException
ApplicationContext.setApplicationContext in interface ApplicationContextAwareapplicationContext - reference to the Spring ApplicationContext.BeansExceptionApplicationContext@NonNull protected ConversionService getConversionService()
ConversionService used to convert data store types
to application domain object types.ConversionService.ConversionServicepublic void setCustomPdxSerializers(@NonNull Map<?,org.apache.geode.pdx.PdxSerializer> customPdxSerializers)
PDX serializers used to customize the serialization for specific
application domain types.customPdxSerializers - mapping containing custom PDX serializers
used to customize the serialization of specific application domain types.IllegalArgumentException - if the custom PDX serializer mapping is null.PdxSerializer,
Map@Deprecated public void setCustomSerializers(Map<Class<?>,org.apache.geode.pdx.PdxSerializer> customSerializers)
setCustomPdxSerializers(Map) instead.@NonNull protected Map<?,org.apache.geode.pdx.PdxSerializer> getCustomPdxSerializers()
mapping of application domain types to custom
PDX serializers used to customize the serialization
for specific application domain types.mapping of application domain types
to custom PDX serializers.PdxSerializer,
Map@Deprecated protected Map<Class<?>,org.apache.geode.pdx.PdxSerializer> getCustomSerializers()
getCustomPdxSerializers() instead.@Nullable protected org.apache.geode.pdx.PdxSerializer getCustomPdxSerializer(@NonNull PersistentProperty<?> property)
entity persistent property.property - PersistentProperty of the entity used to lookup the custom PDX serializer.PdxSerializer for the given entity PersistentProperty,
or null if no custom PdxSerializer could be found.PdxSerializer@Nullable @Deprecated protected org.apache.geode.pdx.PdxSerializer getCustomSerializer(Class<?> type)
getCustomPdxSerializer(PersistentProperty) instead.public void setGemfireInstantiators(@NonNull EntityInstantiators entityInstantiators)
EntityInstantiators used to create the instances
read by this PdxSerializer.entityInstantiators - EntityInstantiators used to create the instances
read by this PdxSerializer; must not be null.EntityInstantiatorpublic void setGemfireInstantiators(@NonNull Map<Class<?>,EntityInstantiator> gemfireInstantiators)
EntityInstantiators used to create the instances
read by this PdxSerializer.gemfireInstantiators - mapping of types to EntityInstantiator objects;
must not be null.EntityInstantiator,
Mapprotected EntityInstantiators getGemfireInstantiators()
EntityInstantiators handling instantiation for Pivotal GemFire persistent entities.EntityInstantiators handling instantiation for Pivotal GemFire persistent entities.EntityInstantiatorsprotected EntityInstantiator getInstantiatorFor(PersistentEntity entity)
entity - the PersistentEntity object used to lookup the custom EntityInstantiator.EntityInstantiator,
PersistentEntity@NonNull protected org.slf4j.Logger getLogger()
Logger used to log messages
about the functions of this PdxSerializer.Logger.Logger@NonNull protected GemfireMappingContext getMappingContext()
mapping context used to handling mapping
logic between Pivotal GemFire persistent entities and application domain object types.mapping context for Pivotal GemFire.GemfireMappingContextprotected GemfirePersistentEntity<?> getPersistentEntity(@NonNull Object entity)
PersistentEntity meta-data for the given entity object.entity - actual persistent entity, application domain object.PersistentEntity meta-data for the given entity object.GemfirePersistentEntity,
getPersistentEntity(Class)protected GemfirePersistentEntity<?> getPersistentEntity(@NonNull Class<?> entityType)
PersistentEntity meta-data for the given entity Class type.entityType - Class type of the actual persistent entity, application domain object Class.PersistentEntity meta-data for the given entity Class type.GemfirePersistentEntity,
getMappingContext()public void setTypeFilters(@Nullable Predicate<Class<?>> typeFilters)
type filters used to filter types serializable
by this PDX serializer.
This operation is null-safe and rather than overriding the existing type filters,
this set operation combines the given type filters with
the exiting type filters joined by and.typeFilters - type filters used to to filter type serializable
by this PDX serializer.Predicateprotected Predicate<Class<?>> getTypeFilters()
type filter.Predicatepublic Object fromData(Class<?> type, org.apache.geode.pdx.PdxReader reader)
fromData in interface org.apache.geode.pdx.PdxSerializerpublic boolean toData(Object value, org.apache.geode.pdx.PdxWriter writer)
toData in interface org.apache.geode.pdx.PdxSerializerCopyright © 2011–2018 Pivotal Software, Inc.. All rights reserved.