Class CouchbaseMappingContext
java.lang.Object
org.springframework.data.mapping.context.AbstractMappingContext<BasicCouchbasePersistentEntity<?>,CouchbasePersistentProperty>
org.springframework.data.couchbase.core.mapping.CouchbaseMappingContext
- All Implemented Interfaces:
Aware
,InitializingBean
,ApplicationContextAware
,ApplicationEventPublisherAware
,MappingContext<BasicCouchbasePersistentEntity<?>,
CouchbasePersistentProperty>
public class CouchbaseMappingContext
extends AbstractMappingContext<BasicCouchbasePersistentEntity<?>,CouchbasePersistentProperty>
implements ApplicationContextAware
Default implementation of a
MappingContext
for Couchbase using
BasicCouchbasePersistentEntity
and BasicCouchbasePersistentProperty
as primary abstractions.- Author:
- Michael Nitschinger, Michael Reiche
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected Optional<BasicCouchbasePersistentEntity<?>>
addPersistentEntity
(TypeInformation<?> typeInformation) override method from AbstractMappingContext as that method will not publishEvent() if it finds the entity has already been cachedprotected <T> BasicCouchbasePersistentEntity<?>
createPersistentEntity
(TypeInformation<T> typeInformation) Creates a concrete entity based out of the type information passed.protected CouchbasePersistentProperty
createPersistentProperty
(Property property, BasicCouchbasePersistentEntity<?> owner, SimpleTypeHolder simpleTypeHolder) Creates a concrete property based on the field information and entity.getPersistentEntity
(TypeInformation<?> typeInformation) override method from AbstractMappingContext as that method will not publishEvent() if it finds the entity has already been cached.boolean
void
setApplicationContext
(ApplicationContext applicationContext) Sets (or overrides) the current application context.void
setApplicationEventPublisher
(ApplicationEventPublisher applicationEventPublisher) void
setAutoIndexCreation
(boolean autoCreateIndexes) void
setFieldNamingStrategy
(FieldNamingStrategy fieldNamingStrategy) Configures theFieldNamingStrategy
to be used to determine the field name if no manual mapping is applied.void
setIndexCreator
(CouchbasePersistentEntityIndexCreator indexCreator) capture the indexCreator when it has been added as a listener. only publishEvent() if the indexCreator hasn't already seen the class.Methods inherited from class org.springframework.data.mapping.context.AbstractMappingContext
addPersistentEntity, afterPropertiesSet, doFindPersistentPropertyPaths, findPersistentPropertyPaths, getManagedTypes, getPersistentEntities, getPersistentEntity, getPersistentEntity, getPersistentPropertyPath, getPersistentPropertyPath, hasPersistentEntityFor, initialize, setInitialEntitySet, setManagedTypes, setSimpleTypeHolder, setStrict, shouldCreatePersistentEntityFor
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.data.mapping.context.MappingContext
getRequiredPersistentEntity, getRequiredPersistentEntity, getRequiredPersistentEntity
-
Constructor Details
-
CouchbaseMappingContext
public CouchbaseMappingContext()
-
-
Method Details
-
setFieldNamingStrategy
Configures theFieldNamingStrategy
to be used to determine the field name if no manual mapping is applied. Defaults to a strategy using the plain property name.- Parameters:
fieldNamingStrategy
- theFieldNamingStrategy
to be used to determine the field name if no manual mapping is applied.
-
createPersistentEntity
protected <T> BasicCouchbasePersistentEntity<?> createPersistentEntity(TypeInformation<T> typeInformation) Creates a concrete entity based out of the type information passed.- Specified by:
createPersistentEntity
in classAbstractMappingContext<BasicCouchbasePersistentEntity<?>,
CouchbasePersistentProperty> - Type Parameters:
T
- the type for the corresponding type information.- Parameters:
typeInformation
- type information of the entity to create.- Returns:
- the constructed entity.
-
createPersistentProperty
protected CouchbasePersistentProperty createPersistentProperty(Property property, BasicCouchbasePersistentEntity<?> owner, SimpleTypeHolder simpleTypeHolder) Creates a concrete property based on the field information and entity.- Specified by:
createPersistentProperty
in classAbstractMappingContext<BasicCouchbasePersistentEntity<?>,
CouchbasePersistentProperty> - Parameters:
property
- the property descriptor.owner
- the entity which owns the property.simpleTypeHolder
- the type holder.- Returns:
- the constructed property.
-
setApplicationContext
Sets (or overrides) the current application context.- Specified by:
setApplicationContext
in interfaceApplicationContextAware
- Overrides:
setApplicationContext
in classAbstractMappingContext<BasicCouchbasePersistentEntity<?>,
CouchbasePersistentProperty> - Parameters:
applicationContext
- the application context to be assigned.- Throws:
BeansException
- if the context can not be set properly.
-
setApplicationEventPublisher
- Specified by:
setApplicationEventPublisher
in interfaceApplicationEventPublisherAware
- Overrides:
setApplicationEventPublisher
in classAbstractMappingContext<BasicCouchbasePersistentEntity<?>,
CouchbasePersistentProperty>
-
isAutoIndexCreation
public boolean isAutoIndexCreation() -
setAutoIndexCreation
public void setAutoIndexCreation(boolean autoCreateIndexes) -
addPersistentEntity
protected Optional<BasicCouchbasePersistentEntity<?>> addPersistentEntity(TypeInformation<?> typeInformation) override method from AbstractMappingContext as that method will not publishEvent() if it finds the entity has already been cached- Overrides:
addPersistentEntity
in classAbstractMappingContext<BasicCouchbasePersistentEntity<?>,
CouchbasePersistentProperty> - Parameters:
typeInformation
- - entity type
-
getPersistentEntity
override method from AbstractMappingContext as that method will not publishEvent() if it finds the entity has already been cached. Instead, user our own addPersistEntity that will.- Specified by:
getPersistentEntity
in interfaceMappingContext<BasicCouchbasePersistentEntity<?>,
CouchbasePersistentProperty> - Overrides:
getPersistentEntity
in classAbstractMappingContext<BasicCouchbasePersistentEntity<?>,
CouchbasePersistentProperty> - Parameters:
typeInformation
- - entity type
-
setIndexCreator
capture the indexCreator when it has been added as a listener. only publishEvent() if the indexCreator hasn't already seen the class.- Parameters:
indexCreator
-
-