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
,
PersistentEntity
,
PersistentPropertyAccessor
,
PersistentEntityParameterValueProvider
,
SpELContext
,
PdxReader
,
PdxSerializer
,
PdxWriter
Modifier and Type | Field and Description |
---|---|
protected org.apache.commons.logging.Log |
log |
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() |
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() |
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 GemfireMappingContext |
getMappingContext() |
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) |
void |
setCustomSerializers(Map<Class<?>,org.apache.geode.pdx.PdxSerializer> customSerializers)
Configures custom PDX serializers to use for specific class types.
|
void |
setGemfireInstantiators(Map<Class<?>,EntityInstantiator> gemfireInstantiators)
Configures the
EntityInstantiator s 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
setApplicationContext
in interface ApplicationContextAware
BeansException
protected ConversionService getConversionService()
public void setCustomSerializers(Map<Class<?>,org.apache.geode.pdx.PdxSerializer> customSerializers)
customSerializers
- a mapping of domain object class types and their corresponding PDX serializer.protected Map<Class<?>,org.apache.geode.pdx.PdxSerializer> getCustomSerializers()
public void setGemfireInstantiators(Map<Class<?>,EntityInstantiator> gemfireInstantiators)
EntityInstantiator
s used to create the instances read by this PdxSerializer.gemfireInstantiators
- must not be null.protected EntityInstantiators getGemfireInstantiators()
protected GemfireMappingContext 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
protected org.apache.geode.pdx.PdxSerializer getCustomSerializer(Class<?> type)
type
- the Class type of the object to (de)serialize.getCustomSerializers()
,
PdxSerializer
protected EntityInstantiator getInstantiatorFor(PersistentEntity entity)
entity
- the PersistentEntity object used to lookup the custom EntityInstantiator.EntityInstantiator
,
PersistentEntity
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()
Copyright © 2011–2017 Pivotal Software, Inc.. All rights reserved.