@Configuration public abstract class AbstractMongoConfiguration extends Object
| Constructor and Description |
|---|
AbstractMongoConfiguration() |
| 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. |
CustomConversions |
customConversions()
Register custom
Converters in a CustomConversions object if required. |
protected FieldNamingStrategy |
fieldNamingStrategy()
Configures a
FieldNamingStrategy on the MongoMappingContext instance created. |
protected String |
getAuthenticationDatabaseName()
Deprecated.
since 1.7.
MongoClient should hold authentication data within
MongoClient.getCredentialsList() |
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 String |
getMappingBasePackage()
Deprecated.
use
getMappingBasePackages() instead. |
protected Collection<String> |
getMappingBasePackages()
Returns the base packages to scan for MongoDB mapped entities at startup.
|
protected UserCredentials |
getUserCredentials()
Deprecated.
since 1.7.
MongoClient should hold authentication data within
MongoClient.getCredentialsList() |
IsNewStrategyFactory |
isNewStrategyFactory()
Returns a
MappingContextIsNewStrategyFactory wrapped into a CachingIsNewStrategyFactory. |
MappingMongoConverter |
mappingMongoConverter()
|
abstract com.mongodb.Mongo |
mongo()
Return the
Mongo instance to connect to. |
MongoDbFactory |
mongoDbFactory()
Creates a
SimpleMongoDbFactory to be used by the MongoTemplate. |
MongoMappingContext |
mongoMappingContext()
Creates a
MongoMappingContext equipped with entity classes scanned from the mapping base package. |
MongoTemplate |
mongoTemplate()
Creates a
MongoTemplate. |
protected Set<Class<?>> |
scanForEntities(String basePackage)
Scans the given base package for entities, i.e.
|
protected abstract String getDatabaseName()
@Deprecated protected String getAuthenticationDatabaseName()
MongoClient should hold authentication data within
MongoClient.getCredentialsList()getDatabaseName() later on effectively.public abstract com.mongodb.Mongo mongo()
throws Exception
Mongo instance to connect to. Annotate with Bean in case you want to expose a
Mongo instance to the ApplicationContext.Exception@Bean public MongoTemplate mongoTemplate() throws Exception
MongoTemplate.Exception@Bean public MongoDbFactory mongoDbFactory() throws Exception
SimpleMongoDbFactory to be used by the MongoTemplate. Will use the Mongo instance
configured in mongo().Exceptionmongo(),
mongoTemplate()@Deprecated protected String getMappingBasePackage()
getMappingBasePackages() instead.Documents. Will return the package name of the configuration
class' (the concrete class, not this one here) by default. So if you have a com.acme.AppConfig extending
AbstractMongoConfiguration the base package will be considered com.acme unless the method is
overridden to implement alternate behavior.Document classes or null to not enable scanning for
entities.protected Collection<String> getMappingBasePackages()
com.acme.AppConfig extending AbstractMongoConfiguration 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.@Deprecated protected UserCredentials getUserCredentials()
MongoClient should hold authentication data within
MongoClient.getCredentialsList()UserCredentials to be used when connecting to the MongoDB instance or null if none shall
be used.@Bean public MongoMappingContext mongoMappingContext() throws ClassNotFoundException
MongoMappingContext equipped with entity classes scanned from the mapping base package.ClassNotFoundExceptiongetMappingBasePackage()@Bean public IsNewStrategyFactory isNewStrategyFactory() throws ClassNotFoundException
MappingContextIsNewStrategyFactory wrapped into a CachingIsNewStrategyFactory.ClassNotFoundException@Bean public CustomConversions customConversions()
Converters in a CustomConversions object if required. These
CustomConversions will be registered with the mappingMongoConverter() and
mongoMappingContext(). Returns an empty CustomConversions instance by default.@Bean public MappingMongoConverter mappingMongoConverter() throws Exception
MappingMongoConverter using the configured mongoDbFactory() and
mongoMappingContext(). Will get customConversions() applied.ExceptioncustomConversions(),
mongoMappingContext(),
mongoDbFactory()protected Set<Class<?>> getInitialEntitySet() throws ClassNotFoundException
Document. By default, it scans for entities in
all packages returned by getMappingBasePackages().ClassNotFoundExceptiongetMappingBasePackages()protected Set<Class<?>> scanForEntities(String basePackage) throws ClassNotFoundException
Document and
Persistent.basePackage - must not be null.ClassNotFoundExceptionprotected boolean abbreviateFieldNames()
CamelCaseAbbreviatingFieldNamingStrategy on the MongoMappingContext instance created. For advanced
customization needs, consider overriding mappingMongoConverter().protected FieldNamingStrategy fieldNamingStrategy()
FieldNamingStrategy on the MongoMappingContext instance created.Copyright © 2011-2015–2017 Pivotal Software, Inc.. All rights reserved.