public abstract class MongoConfigurationSupport extends Object
Constructor and Description |
---|
MongoConfigurationSupport() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
abbreviateFieldNames()
Configures whether to abbreviate field names for domain objects by configuring a
CamelCaseAbbreviatingFieldNamingStrategy on the MongoMappingContext instance created. |
protected boolean |
autoIndexCreation()
Configure whether to automatically create indices for domain types by deriving the
IndexDefinition from the entity or not. |
protected void |
configureClientSettings(com.mongodb.MongoClientSettings.Builder builder)
Configure
MongoClientSettings via its MongoClientSettings.Builder API. |
protected void |
configureConverters(MongoCustomConversions.MongoConverterConfigurationAdapter converterConfigurationAdapter)
Configuration hook for
MongoCustomConversions creation. |
MongoCustomConversions |
customConversions()
Register custom
Converter s in a CustomConversions object if required. |
protected FieldNamingStrategy |
fieldNamingStrategy()
Configures a
FieldNamingStrategy on the MongoMappingContext instance created. |
protected abstract String |
getDatabaseName()
Return the name of the database to connect to.
|
protected Set<Class<?>> |
getInitialEntitySet()
Scans the mapping base package for classes annotated with
Document . |
protected Collection<String> |
getMappingBasePackages()
Returns the base packages to scan for MongoDB mapped entities at startup.
|
protected com.mongodb.MongoClientSettings |
mongoClientSettings()
Return the
MongoClientSettings used to create the actual MongoClient. |
MongoMappingContext |
mongoMappingContext(MongoCustomConversions customConversions)
Creates a
MongoMappingContext equipped with entity classes scanned from the mapping base package. |
protected Set<Class<?>> |
scanForEntities(String basePackage)
Scans the given base package for entities, i.e.
|
protected abstract String getDatabaseName()
protected Collection<String> getMappingBasePackages()
com.acme.AppConfig
extending MongoConfigurationSupport
the base package will be considered
com.acme
unless the method is overridden to implement alternate behavior.Document
classes or an empty collection to not enable scanning
for entities.@Bean public MongoMappingContext mongoMappingContext(MongoCustomConversions customConversions) throws ClassNotFoundException
MongoMappingContext
equipped with entity classes scanned from the mapping base package.ClassNotFoundException
getMappingBasePackages()
@Bean public MongoCustomConversions customConversions()
Converter
s in a CustomConversions
object if required. These
CustomConversions
will be registered with the
MappingMongoConverter
and MongoMappingContext
.
Returns an empty MongoCustomConversions
instance by default.
NOTE: Use #configureConverters(MongoConverterConfigurationAdapter)
to configure MongoDB
native simple types and register custom converters
.
protected void configureConverters(MongoCustomConversions.MongoConverterConfigurationAdapter converterConfigurationAdapter)
MongoCustomConversions
creation.converterConfigurationAdapter
- never null.MongoCustomConversions.MongoConverterConfigurationAdapter.useNativeDriverJavaTimeCodecs()
,
MongoCustomConversions.MongoConverterConfigurationAdapter.useSpringDataJavaTimeCodecs()
protected Set<Class<?>> getInitialEntitySet() throws ClassNotFoundException
Document
. By default, it scans for entities in
all packages returned by getMappingBasePackages()
.ClassNotFoundException
getMappingBasePackages()
protected Set<Class<?>> scanForEntities(String basePackage) throws ClassNotFoundException
Document
.basePackage
- must not be null.ClassNotFoundException
protected boolean abbreviateFieldNames()
CamelCaseAbbreviatingFieldNamingStrategy
on the MongoMappingContext
instance created.protected FieldNamingStrategy fieldNamingStrategy()
FieldNamingStrategy
on the MongoMappingContext
instance created.protected boolean autoIndexCreation()
IndexDefinition
from the entity or not.protected com.mongodb.MongoClientSettings mongoClientSettings()
MongoClientSettings
used to create the actual MongoClient. #configureClientSettings(Builder)
to alter the setup.protected void configureClientSettings(com.mongodb.MongoClientSettings.Builder builder)
MongoClientSettings
via its MongoClientSettings.Builder
API.builder
- never null.Copyright © 2011–2022 Pivotal Software, Inc.. All rights reserved.