org.springframework.datastore.mapping
Interface MappingContext

All Known Implementing Classes:
AbstractMappingContext, KeyValueMappingContext

public interface MappingContext

This interface defines the overall context including all known PersistentEntity instances and methods to obtain instances on demand

This interface is used internally to establish associations between entities and also at runtime to obtain entities by name

The generic type parameters T & R are used to specify the mapped form of a class (example Table) and property (example Column) respectively.

Used instances of the Datastore interface to discover how to persist objects

Since:
1.0

Nested Class Summary
static interface MappingContext.Listener
          Implementors can register for events when the mapping context changes
 
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
 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
 MappingFactory getMappingFactory()
          Obtains the MappingFactory instance
 MappingConfigurationStrategy getMappingSyntaxStrategy()
          Returns the syntax reader used to interpret the entity mapping syntax
 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
 

Method Detail

getPersistentEntities

Collection<PersistentEntity> getPersistentEntities()
Obtains a list of PersistentEntity instances

Returns:
A list of PersistentEntity instances

getPersistentEntity

PersistentEntity getPersistentEntity(String name)
Obtains a PersistentEntity by name

Parameters:
name - The name of the entity
Returns:
The entity or null

getChildEntityByDiscriminator

PersistentEntity getChildEntityByDiscriminator(PersistentEntity root,
                                               String discriminator)
Obtains a child of the given root entity using the given discriminator

Parameters:
root - The root entity
discriminator - The discriminator
Returns:
The child entity or null if non exists

addPersistentEntity

PersistentEntity addPersistentEntity(Class javaClass)
Adds a PersistentEntity instance

Parameters:
javaClass - The Java class representing the entity
Returns:
The PersistentEntity instance

addEntityValidator

void addEntityValidator(PersistentEntity entity,
                        org.springframework.validation.Validator validator)
Adds a validator to be used by the entity for validation

Parameters:
entity - The PersistentEntity
validator - The validator

addTypeConverter

void addTypeConverter(org.springframework.core.convert.converter.Converter converter)
Add a converter used to convert property values to and from the datastore

Parameters:
converter - The converter to add

getConversionService

org.springframework.core.convert.support.GenericConversionService getConversionService()
Obtains the ConversionService instance to use for type conversion

Returns:
The conversion service instance

getEntityValidator

org.springframework.validation.Validator getEntityValidator(PersistentEntity entity)
Obtains a validator for the given entity

Parameters:
entity - The entity
Returns:
A validator or null if none exists for the given entity

getMappingSyntaxStrategy

MappingConfigurationStrategy getMappingSyntaxStrategy()
Returns the syntax reader used to interpret the entity mapping syntax

Returns:
The SyntaxReader

getMappingFactory

MappingFactory getMappingFactory()
Obtains the MappingFactory instance

Returns:
The mapping factory instance

isPersistentEntity

boolean isPersistentEntity(Class type)
Returns whether the specified class is a persistent entity

Parameters:
type - The type to check
Returns:
True if it is

isPersistentEntity

boolean isPersistentEntity(Object value)
Returns whether the specified value is a persistent entity

Parameters:
value - The value to check
Returns:
True if it is

getProxyFactory

ProxyFactory getProxyFactory()
Factory used for creating proxies

Returns:
The proxy factory

setProxyFactory

void setProxyFactory(ProxyFactory factory)
Factory to use for creating proxies

Parameters:
factory - The proxy factory

addMappingContextListener

void addMappingContextListener(MappingContext.Listener listener)
Adds a new mapping context listener instance

Parameters:
listener - The listener