org.springframework.datastore.mapping
Class AbstractMappingContext

java.lang.Object
  extended by org.springframework.datastore.mapping.AbstractMappingContext
All Implemented Interfaces:
MappingContext
Direct Known Subclasses:
KeyValueMappingContext

public abstract class AbstractMappingContext
extends Object
implements MappingContext

Abstract implementation of the MappingContext interface

Since:
1.0

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.springframework.datastore.mapping.MappingContext
MappingContext.Listener
 
Field Summary
protected  org.springframework.core.convert.support.GenericConversionService conversionService
           
protected  Map<PersistentEntity,org.springframework.validation.Validator> entityValidators
           
protected  Collection<MappingContext.Listener> eventListeners
           
protected  Collection<PersistentEntity> persistentEntities
           
protected  Map<PersistentEntity,Map<String,PersistentEntity>> persistentEntitiesByDiscriminator
           
protected  Map<String,PersistentEntity> persistentEntitiesByName
           
protected  ProxyFactory proxyFactory
           
 
Constructor Summary
AbstractMappingContext()
           
 
Method Summary
 void addEntityValidator(PersistentEntity entity, org.springframework.validation.Validator validator)
          Adds a validator to be used by the entity for validation
 void addMappingContextListener(MappingContext.Listener listener)
          Adds a new mapping context listener instance
 PersistentEntity addPersistentEntity(Class javaClass)
          Adds a PersistentEntity instance
 void addTypeConverter(org.springframework.core.convert.converter.Converter converter)
          Add a converter used to convert property values to and from the datastore
protected abstract  PersistentEntity createPersistentEntity(Class javaClass)
           
 PersistentEntity getChildEntityByDiscriminator(PersistentEntity root, String discriminator)
          Obtains a child of the given root entity using the given discriminator
 org.springframework.core.convert.support.GenericConversionService getConversionService()
          Obtains the ConversionService instance to use for type conversion
 org.springframework.validation.Validator getEntityValidator(PersistentEntity entity)
          Obtains a validator for the given entity
 Collection<PersistentEntity> getPersistentEntities()
          Obtains a list of PersistentEntity instances
 PersistentEntity getPersistentEntity(String name)
          Obtains a PersistentEntity by name
 ProxyFactory getProxyFactory()
          Factory used for creating proxies
 boolean isPersistentEntity(Class type)
          Returns whether the specified class is a persistent entity
 boolean isPersistentEntity(Object value)
          Returns whether the specified value is a persistent entity
 void setProxyFactory(ProxyFactory factory)
          Factory to use for creating proxies
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.datastore.mapping.MappingContext
getMappingFactory, getMappingSyntaxStrategy
 

Field Detail

persistentEntities

protected Collection<PersistentEntity> persistentEntities

persistentEntitiesByName

protected Map<String,PersistentEntity> persistentEntitiesByName

persistentEntitiesByDiscriminator

protected Map<PersistentEntity,Map<String,PersistentEntity>> persistentEntitiesByDiscriminator

entityValidators

protected Map<PersistentEntity,org.springframework.validation.Validator> entityValidators

eventListeners

protected Collection<MappingContext.Listener> eventListeners

conversionService

protected org.springframework.core.convert.support.GenericConversionService conversionService

proxyFactory

protected ProxyFactory proxyFactory
Constructor Detail

AbstractMappingContext

public AbstractMappingContext()
Method Detail

getConversionService

public org.springframework.core.convert.support.GenericConversionService getConversionService()
Description copied from interface: MappingContext
Obtains the ConversionService instance to use for type conversion

Specified by:
getConversionService in interface MappingContext
Returns:
The conversion service instance

getProxyFactory

public ProxyFactory getProxyFactory()
Description copied from interface: MappingContext
Factory used for creating proxies

Specified by:
getProxyFactory in interface MappingContext
Returns:
The proxy factory

addMappingContextListener

public void addMappingContextListener(MappingContext.Listener listener)
Description copied from interface: MappingContext
Adds a new mapping context listener instance

Specified by:
addMappingContextListener in interface MappingContext
Parameters:
listener - The listener

setProxyFactory

public void setProxyFactory(ProxyFactory factory)
Description copied from interface: MappingContext
Factory to use for creating proxies

Specified by:
setProxyFactory in interface MappingContext
Parameters:
factory - The proxy factory

addTypeConverter

public void addTypeConverter(org.springframework.core.convert.converter.Converter converter)
Description copied from interface: MappingContext
Add a converter used to convert property values to and from the datastore

Specified by:
addTypeConverter in interface MappingContext
Parameters:
converter - The converter to add

getEntityValidator

public org.springframework.validation.Validator getEntityValidator(PersistentEntity entity)
Description copied from interface: MappingContext
Obtains a validator for the given entity

Specified by:
getEntityValidator in interface MappingContext
Parameters:
entity - The entity
Returns:
A validator or null if none exists for the given entity

addEntityValidator

public void addEntityValidator(PersistentEntity entity,
                               org.springframework.validation.Validator validator)
Description copied from interface: MappingContext
Adds a validator to be used by the entity for validation

Specified by:
addEntityValidator in interface MappingContext
Parameters:
entity - The PersistentEntity
validator - The validator

addPersistentEntity

public final PersistentEntity addPersistentEntity(Class javaClass)
Description copied from interface: MappingContext
Adds a PersistentEntity instance

Specified by:
addPersistentEntity in interface MappingContext
Parameters:
javaClass - The Java class representing the entity
Returns:
The PersistentEntity instance

getChildEntityByDiscriminator

public PersistentEntity getChildEntityByDiscriminator(PersistentEntity root,
                                                      String discriminator)
Description copied from interface: MappingContext
Obtains a child of the given root entity using the given discriminator

Specified by:
getChildEntityByDiscriminator in interface MappingContext
Parameters:
root - The root entity
discriminator - The discriminator
Returns:
The child entity or null if non exists

createPersistentEntity

protected abstract PersistentEntity createPersistentEntity(Class javaClass)

getPersistentEntities

public Collection<PersistentEntity> getPersistentEntities()
Description copied from interface: MappingContext
Obtains a list of PersistentEntity instances

Specified by:
getPersistentEntities in interface MappingContext
Returns:
A list of PersistentEntity instances

isPersistentEntity

public boolean isPersistentEntity(Class type)
Description copied from interface: MappingContext
Returns whether the specified class is a persistent entity

Specified by:
isPersistentEntity in interface MappingContext
Parameters:
type - The type to check
Returns:
True if it is

isPersistentEntity

public boolean isPersistentEntity(Object value)
Description copied from interface: MappingContext
Returns whether the specified value is a persistent entity

Specified by:
isPersistentEntity in interface MappingContext
Parameters:
value - The value to check
Returns:
True if it is

getPersistentEntity

public PersistentEntity getPersistentEntity(String name)
Description copied from interface: MappingContext
Obtains a PersistentEntity by name

Specified by:
getPersistentEntity in interface MappingContext
Parameters:
name - The name of the entity
Returns:
The entity or null