Spring Data Commons

org.springframework.data.mapping
Class BasicMappingContext

java.lang.Object
  extended by org.springframework.data.mapping.BasicMappingContext
All Implemented Interfaces:
InitializingBean, ApplicationEventPublisherAware, MappingContext

public class BasicMappingContext
extends Object
implements MappingContext, InitializingBean, ApplicationEventPublisherAware

Author:
Jon Brisbin , Oliver Gierke

Field Summary
protected  ApplicationEventPublisher applicationEventPublisher
           
protected  GenericConversionService conversionService
           
protected  org.apache.commons.logging.Log log
           
protected  ConcurrentMap<TypeInformation,PersistentEntity<?>> persistentEntities
           
protected  ConcurrentMap<PersistentEntity<?>,List<Validator>> validators
           
 
Constructor Summary
BasicMappingContext()
           
BasicMappingContext(GenericConversionService conversionService)
           
 
Method Summary
<T> PersistentEntity<T>
addPersistentEntity(Class<T> type)
          Adds a PersistentEntity instance
<T> PersistentEntity<T>
addPersistentEntity(TypeInformation typeInformation)
           
 void afterPropertiesSet()
           
 Association createAssociation(BasicPersistentProperty property)
           
protected
<T> BasicPersistentEntity<T>
createPersistentEntity(TypeInformation typeInformation, MappingContext mappingContext)
           
protected  BasicPersistentProperty createPersistentProperty(Field field, PropertyDescriptor descriptor, TypeInformation information)
           
 List<Validator> getEntityValidators(PersistentEntity<?> entity)
          Obtains a validator for the given entity
 Collection<? extends PersistentEntity<?>> getPersistentEntities()
          Obtains a list of PersistentEntity instances
<T> PersistentEntity<T>
getPersistentEntity(Class<T> type)
           
<T> PersistentEntity<T>
getPersistentEntity(TypeInformation type)
           
<T> PreferredConstructor<T>
getPreferredConstructor(Class<T> type)
           
protected  Class<?> getTargetType(ParameterizedType ptype)
           
protected  Class<?> getTargetType(TypeVariable<?> tv)
           
 boolean isAssociation(Field field, PropertyDescriptor descriptor)
           
 boolean isPersistentEntity(Class<?> type)
           
 boolean isPersistentEntity(Object value)
          Returns whether the specified value is a persistent entity
 boolean isPersistentProperty(Field field, PropertyDescriptor descriptor)
           
protected  boolean isTransient(Field field)
           
 void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
           
 void setCustomSimpleTypes(List<Class<?>> customSimpleTypes)
           
 void setInitialEntitySet(Set<Class<?>> initialEntitySet)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected org.apache.commons.logging.Log log

applicationEventPublisher

protected ApplicationEventPublisher applicationEventPublisher

persistentEntities

protected ConcurrentMap<TypeInformation,PersistentEntity<?>> persistentEntities

validators

protected ConcurrentMap<PersistentEntity<?>,List<Validator>> validators

conversionService

protected final GenericConversionService conversionService
Constructor Detail

BasicMappingContext

public BasicMappingContext()

BasicMappingContext

public BasicMappingContext(GenericConversionService conversionService)
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<Class<?>> initialEntitySet)

getPersistentEntities

public Collection<? extends 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

getPersistentEntity

public <T> PersistentEntity<T> getPersistentEntity(Class<T> type)
Specified by:
getPersistentEntity in interface MappingContext

getPersistentEntity

public <T> PersistentEntity<T> getPersistentEntity(TypeInformation type)
Specified by:
getPersistentEntity in interface MappingContext

addPersistentEntity

public <T> PersistentEntity<T> addPersistentEntity(Class<T> type)
Description copied from interface: MappingContext
Adds a PersistentEntity instance

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

addPersistentEntity

public <T> PersistentEntity<T> addPersistentEntity(TypeInformation typeInformation)

getEntityValidators

public List<Validator> getEntityValidators(PersistentEntity<?> entity)
Description copied from interface: MappingContext
Obtains a validator for the given entity

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

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

isPersistentEntity

public boolean isPersistentEntity(Class<?> type)

createPersistentEntity

protected <T> BasicPersistentEntity<T> createPersistentEntity(TypeInformation typeInformation,
                                                              MappingContext mappingContext)
                                                   throws MappingConfigurationException
Throws:
MappingConfigurationException

createPersistentProperty

protected BasicPersistentProperty createPersistentProperty(Field field,
                                                           PropertyDescriptor descriptor,
                                                           TypeInformation information)
                                                    throws MappingConfigurationException
Throws:
MappingConfigurationException

isPersistentProperty

public boolean isPersistentProperty(Field field,
                                    PropertyDescriptor descriptor)
                             throws MappingConfigurationException
Throws:
MappingConfigurationException

getPreferredConstructor

public <T> PreferredConstructor<T> getPreferredConstructor(Class<T> type)
                                                throws MappingConfigurationException
Throws:
MappingConfigurationException

isAssociation

public boolean isAssociation(Field field,
                             PropertyDescriptor descriptor)
                      throws MappingConfigurationException
Throws:
MappingConfigurationException

createAssociation

public Association createAssociation(BasicPersistentProperty property)

isTransient

protected boolean isTransient(Field field)

getTargetType

protected Class<?> getTargetType(TypeVariable<?> tv)

getTargetType

protected Class<?> getTargetType(ParameterizedType ptype)

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
Exception

Spring Data Commons

Copyright © 2011. All Rights Reserved.