Spring Data Commons

org.springframework.data.mapping
Class AbstractMappingContext<E extends MutablePersistentEntity<?,P>,P extends PersistentProperty<P>>

java.lang.Object
  extended by org.springframework.data.mapping.AbstractMappingContext<E,P>
All Implemented Interfaces:
InitializingBean, ApplicationEventPublisherAware, MappingContext<E,P>

public abstract class AbstractMappingContext<E extends MutablePersistentEntity<?,P>,P extends PersistentProperty<P>>
extends Object
implements MappingContext<E,P>, InitializingBean, ApplicationEventPublisherAware

Base class to build mapping metadata and thus create instances of PersistentEntity and PersistentProperty.

Author:
Jon Brisbin , Oliver Gierke

Constructor Summary
AbstractMappingContext()
           
 
Method Summary
protected  E addPersistentEntity(Class<?> type)
          Adds the given type to the MappingContext.
protected  E addPersistentEntity(TypeInformation<?> typeInformation)
          Adds the given TypeInformation to the MappingContext.
 void afterPropertiesSet()
           
protected abstract
<T> E
createPersistentEntity(TypeInformation<T> typeInformation)
           
protected abstract  P createPersistentProperty(Field field, PropertyDescriptor descriptor, E owner)
           
 List<Validator> getEntityValidators(E entity)
          Obtains a validator for the given entity TODO: Why do we need validators at the MappingContext?
 Collection<E> getPersistentEntities()
          Obtains a list of PersistentEntity instances
 E getPersistentEntity(Class<?> type)
           
 E getPersistentEntity(TypeInformation<?> type)
           
 void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
           
 void setCustomSimpleTypes(List<Class<?>> customSimpleTypes)
           
 void setInitialEntitySet(Set<? extends Class<?>> initialEntitySet)
          Sets the Set of types to populate the context initially.
 void setStrict(boolean strict)
          Configures whether the MappingContext is in strict mode which means, that it will throw MappingExceptions in case one tries to lookup a PersistentEntity not already in the context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractMappingContext

public AbstractMappingContext()
Method Detail

setCustomSimpleTypes

public void setCustomSimpleTypes(List<Class<?>> customSimpleTypes)
Parameters:
customSimpleTypes - the customSimpleTypes to set

setApplicationEventPublisher

public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
Specified by:
setApplicationEventPublisher in interface ApplicationEventPublisherAware

setInitialEntitySet

public void setInitialEntitySet(Set<? extends Class<?>> initialEntitySet)
Sets the Set of types to populate the context initially.

Parameters:
initialEntitySet -

setStrict

public void setStrict(boolean strict)
Configures whether the MappingContext is in strict mode which means, that it will throw MappingExceptions in case one tries to lookup a PersistentEntity not already in the context. This defaults to false so that unknown types will be transparently added to the MappingContext if not known in advance.

Parameters:
strict -

getPersistentEntities

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

Specified by:
getPersistentEntities in interface MappingContext<E extends MutablePersistentEntity<?,P>,P extends PersistentProperty<P>>
Returns:
A list of PersistentEntity instances

getPersistentEntity

public E getPersistentEntity(Class<?> type)
Specified by:
getPersistentEntity in interface MappingContext<E extends MutablePersistentEntity<?,P>,P extends PersistentProperty<P>>

getPersistentEntity

public E getPersistentEntity(TypeInformation<?> type)
Specified by:
getPersistentEntity in interface MappingContext<E extends MutablePersistentEntity<?,P>,P extends PersistentProperty<P>>

addPersistentEntity

protected E addPersistentEntity(Class<?> type)
Adds the given type to the MappingContext.

Parameters:
type -
Returns:

addPersistentEntity

protected E addPersistentEntity(TypeInformation<?> typeInformation)
Adds the given TypeInformation to the MappingContext.

Parameters:
typeInformation -
Returns:

getEntityValidators

public List<Validator> getEntityValidators(E entity)
Description copied from interface: MappingContext
Obtains a validator for the given entity TODO: Why do we need validators at the MappingContext?

Specified by:
getEntityValidators in interface MappingContext<E extends MutablePersistentEntity<?,P>,P extends PersistentProperty<P>>
Parameters:
entity - The entity
Returns:
A validator or null if none exists for the given entity

createPersistentEntity

protected abstract <T> E createPersistentEntity(TypeInformation<T> typeInformation)

createPersistentProperty

protected abstract P createPersistentProperty(Field field,
                                              PropertyDescriptor descriptor,
                                              E owner)

afterPropertiesSet

public void afterPropertiesSet()
Specified by:
afterPropertiesSet in interface InitializingBean

Spring Data Commons

Copyright © 2011. All Rights Reserved.