public class MappingPdxSerializer extends Object implements org.apache.geode.pdx.PdxSerializer, ApplicationContextAware
PdxSerializer
implementation that uses a Spring Data GemFire GemfireMappingContext
to read and write entities.ApplicationContext
,
ApplicationContextAware
,
ConversionService
,
EntityInstantiator
,
EntityInstantiators
,
PersistentEntity
,
PersistentPropertyAccessor
,
ConvertingPropertyAccessor
,
PdxReader
,
PdxSerializer
,
PdxWriter
Constructor and Description |
---|
MappingPdxSerializer()
Creates a new
MappingPdxSerializer using the default GemfireMappingContext
and DefaultConversionService . |
MappingPdxSerializer(GemfireMappingContext mappingContext,
ConversionService conversionService)
|
Modifier and Type | Method and Description |
---|---|
static MappingPdxSerializer |
create(GemfireMappingContext mappingContext,
ConversionService conversionService)
Factory method to construct a new instance of the
MappingPdxSerializer initialized with the given
GemfireMappingContext and Spring ConversionService . |
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 |
getCustomSerializer(Class<?> type)
Looks up and returns a custom PdxSerializer based on the class type of the object to (de)serialize.
|
protected Map<Class<?>,org.apache.geode.pdx.PdxSerializer> |
getCustomSerializers()
|
protected EntityInstantiators |
getGemfireInstantiators()
Returns the configured
EntityInstantiators handling instantiation for 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 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. |
void |
setApplicationContext(ApplicationContext applicationContext)
Configures a reference to the Spring
ApplicationContext . |
void |
setCustomSerializers(Map<Class<?>,org.apache.geode.pdx.PdxSerializer> customSerializers)
Configures custom
PDX serializers used to serialize
specific application class types . |
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 . |
boolean |
toData(Object value,
org.apache.geode.pdx.PdxWriter writer) |
public MappingPdxSerializer()
MappingPdxSerializer
using the default GemfireMappingContext
and DefaultConversionService
.DefaultConversionService
,
GemfireMappingContext
public MappingPdxSerializer(GemfireMappingContext mappingContext, ConversionService conversionService)
mappingContext
- must not be null.conversionService
- must not be null.public static MappingPdxSerializer create(GemfireMappingContext mappingContext, ConversionService conversionService)
MappingPdxSerializer
initialized with the given
GemfireMappingContext
and Spring ConversionService
. If either the GemfireMappingContext
or Spring ConversionService
are null, then this factory method will construct default
instances of each.mappingContext
- GemfireMappingContext
used by this PdxSerializer
to handle mappings
between application domain object types and PDX Serialization meta-data/data.conversionService
- Spring's ConversionService
used to convert PDX deserialized data to application
object property types.MappingPdxSerializer
.ConversionService
,
MappingPdxSerializer
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
ApplicationContext
.setApplicationContext
in interface ApplicationContextAware
applicationContext
- reference to the Spring ApplicationContext
.BeansException
ApplicationContext
protected ConversionService getConversionService()
ConversionService
used to convert data store types
to application domain object types.ConversionService
.ConversionService
public void setCustomSerializers(Map<Class<?>,org.apache.geode.pdx.PdxSerializer> customSerializers)
PDX serializers
used to serialize
specific application class types
.customSerializers
- mapping of application domain object class types
to PDX serializers
used to handle those class types
.IllegalArgumentException
- if the Map
is null.PdxSerializer
,
Map
protected Map<Class<?>,org.apache.geode.pdx.PdxSerializer> getCustomSerializers()
protected org.apache.geode.pdx.PdxSerializer getCustomSerializer(Class<?> type)
type
- the Class type of the object to (de)serialize.getCustomSerializers()
,
PdxSerializer
,
Class
public void setGemfireInstantiators(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.EntityInstantiator
public void setGemfireInstantiators(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
,
Map
protected EntityInstantiators getGemfireInstantiators()
EntityInstantiators
handling instantiation for GemFire persistent entities.EntityInstantiators
handling instantiation for GemFire persistent entities.EntityInstantiators
protected EntityInstantiator getInstantiatorFor(PersistentEntity entity)
entity
- the PersistentEntity object used to lookup the custom EntityInstantiator.EntityInstantiator
,
PersistentEntity
protected org.slf4j.Logger getLogger()
Logger
used to log messages
about the functions of this PdxSerializer
.Logger
.Logger
protected GemfireMappingContext getMappingContext()
mapping context
used to handling mapping
logic between GemFire persistent entities and application domain object types
.mapping context
for Pivotal GemFire.GemfireMappingContext
protected GemfirePersistentEntity<?> getPersistentEntity(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(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 Object fromData(Class<?> type, org.apache.geode.pdx.PdxReader reader)
fromData
in interface org.apache.geode.pdx.PdxSerializer
public boolean toData(Object value, org.apache.geode.pdx.PdxWriter writer)
toData
in interface org.apache.geode.pdx.PdxSerializer
Copyright © 2011–2018 Pivotal Software, Inc.. All rights reserved.