@Configuration public abstract class AbstractMongoConfiguration extends Object
| Constructor and Description |
|---|
AbstractMongoConfiguration() |
| Modifier and Type | Method and Description |
|---|---|
CustomConversions |
customConversions()
Register custom
Converters in a CustomConversions object if required. |
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()
Return the base package to scan for mapped
Documents. |
protected org.springframework.data.authentication.UserCredentials |
getUserCredentials()
Return
UserCredentials to be used when connecting to the MongoDB instance or null if none shall
be used. |
MappingMongoConverter |
mappingMongoConverter()
|
abstract Mongo |
mongo()
Return the
Mongo instance to connect to. |
SimpleMongoDbFactory |
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 abstract String getDatabaseName()
@Bean public abstract Mongo mongo() throws Exception
Mongo instance to connect to.Exception@Bean public MongoTemplate mongoTemplate() throws Exception
MongoTemplate.Exception@Bean public SimpleMongoDbFactory mongoDbFactory() throws Exception
SimpleMongoDbFactory to be used by the MongoTemplate. Will use the Mongo instance
configured in mongo().Exceptionmongo(),
mongoTemplate()protected String getMappingBasePackage()
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
overriden to implement alternate behaviour.Document classes or null to not enable scanning for
entities.protected org.springframework.data.authentication.UserCredentials getUserCredentials()
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 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.ClassNotFoundExceptiongetMappingBasePackage()Copyright © 2012. All Rights Reserved.