public class MongoDatastore extends AbstractDatastore
A Datastore implementation for the Mongo document store.
Modifiers | Name | Description |
---|---|---|
static java.lang.String |
CODEC_ENGINE |
|
static java.lang.String |
INDEX_ATTRIBUTES |
|
static java.lang.String |
SETTING_CONNECTION_STRING |
|
static java.lang.String |
SETTING_DATABASE_NAME |
|
static java.lang.String |
SETTING_DEFAULT_MAPPING |
|
static java.lang.String |
SETTING_ENGINE |
|
static java.lang.String |
SETTING_HOST |
|
static java.lang.String |
SETTING_OPTIONS |
|
static java.lang.String |
SETTING_PASSWORD |
|
static java.lang.String |
SETTING_PORT |
|
static java.lang.String |
SETTING_STATELESS |
|
static java.lang.String |
SETTING_URL |
|
static java.lang.String |
SETTING_USERNAME |
|
protected AutoTimestampEventListener |
autoTimestampEventListener |
|
protected boolean |
codecEngine |
|
protected org.bson.codecs.configuration.CodecRegistry |
codecRegistry |
|
protected ConnectionSources<com.mongodb.MongoClient, MongoConnectionSourceSettings> |
connectionSources |
|
protected java.util.Map<java.lang.String, MongoDatastore> |
datastoresByConnectionSource |
|
protected java.lang.String |
defaultDatabase |
|
protected javax.persistence.FlushModeType |
defaultFlushMode |
|
protected ConfigurableApplicationEventPublisher |
eventPublisher |
|
protected GormEnhancer |
gormEnhancer |
|
protected com.mongodb.MongoClient |
mongo |
|
protected java.util.Map<PersistentEntity, java.lang.String> |
mongoCollections |
|
protected java.util.Map<PersistentEntity, java.lang.String> |
mongoDatabases |
|
protected MultiTenancyMode |
multiTenancyMode |
|
protected boolean |
stateless |
|
protected TenantResolver |
tenantResolver |
|
protected org.springframework.transaction.PlatformTransactionManager |
transactionManager |
Constructor and description |
---|
MongoDatastore
(ConnectionSources<com.mongodb.MongoClient, MongoConnectionSourceSettings> connectionSources, MongoMappingContext mappingContext, ConfigurableApplicationEventPublisher eventPublisher) Configures a new MongoDatastore for the given arguments |
MongoDatastore
(ConnectionSources<com.mongodb.MongoClient, MongoConnectionSourceSettings> connectionSources, ConfigurableApplicationEventPublisher eventPublisher, java.lang.Class... classes) Configures a new MongoDatastore for the given arguments |
MongoDatastore
(com.mongodb.MongoClient mongoClient, org.springframework.core.env.PropertyResolver configuration, MongoMappingContext mappingContext, ConfigurableApplicationEventPublisher eventPublisher) Configures a new MongoDatastore for the given arguments |
MongoDatastore
(com.mongodb.MongoClient mongoClient, org.springframework.core.env.PropertyResolver configuration, ConfigurableApplicationEventPublisher eventPublisher, java.lang.Class... classes) Configures a new MongoDatastore for the given arguments |
MongoDatastore
(com.mongodb.MongoClient mongoClient, org.springframework.core.env.PropertyResolver configuration, java.lang.Class... classes) Configures a new MongoDatastore for the given arguments |
MongoDatastore
(com.mongodb.MongoClient mongoClient, java.lang.Class... classes) Configures a new MongoDatastore for the given arguments |
MongoDatastore
(com.mongodb.MongoClientOptions$Builder clientOptions, org.springframework.core.env.PropertyResolver configuration, MongoMappingContext mappingContext, ConfigurableApplicationEventPublisher eventPublisher) Configures a new MongoDatastore for the given arguments |
MongoDatastore
(com.mongodb.MongoClientOptions$Builder clientOptions, org.springframework.core.env.PropertyResolver configuration, MongoMappingContext mappingContext) Configures a new MongoDatastore for the given arguments |
MongoDatastore
(org.springframework.core.env.PropertyResolver configuration, MongoMappingContext mappingContext, ConfigurableApplicationEventPublisher eventPublisher) Configures a new MongoDatastore for the given arguments |
MongoDatastore
(org.springframework.core.env.PropertyResolver configuration, MongoConnectionSourceFactory connectionSourceFactory, ConfigurableApplicationEventPublisher eventPublisher, java.lang.Class... classes) Configures a new MongoDatastore for the given arguments |
MongoDatastore
(org.springframework.core.env.PropertyResolver configuration, ConfigurableApplicationEventPublisher eventPublisher, java.lang.Class... classes) Configures a new MongoDatastore for the given arguments |
MongoDatastore
(org.springframework.core.env.PropertyResolver configuration, MongoMappingContext mappingContext) Configures a new MongoDatastore for the given arguments |
MongoDatastore
(org.springframework.core.env.PropertyResolver configuration, java.lang.Class... classes) Configures a new MongoDatastore for the given arguments |
MongoDatastore
(java.util.Map<java.lang.String, java.lang.Object> configuration, ConfigurableApplicationEventPublisher eventPublisher, java.lang.Class... classes) Configures a new MongoDatastore for the given arguments |
MongoDatastore
(java.util.Map<java.lang.String, java.lang.Object> configuration, java.lang.Class... classes) Configures a new MongoDatastore for the given arguments |
MongoDatastore
(java.util.Map<java.lang.String, java.lang.Object> configuration, MongoMappingContext mappingContext) Configures a new MongoDatastore for the given arguments |
MongoDatastore
(MongoMappingContext mappingContext) Configures a new MongoDatastore for the given arguments |
MongoDatastore
(java.lang.Class... classes) Configures a new MongoDatastore for the given arguments |
Type Params | Return Type | Name and description |
---|---|---|
|
void |
buildIndex() Builds the MongoDB index for this datastore |
|
void |
close() |
|
protected static ConnectionSources<com.mongodb.MongoClient, MongoConnectionSourceSettings> |
createDefaultConnectionSources(com.mongodb.MongoClient mongoClient, org.springframework.core.env.PropertyResolver configuration, MongoMappingContext mappingContext) Creates the connection sources for an existing com.mongodb.MongoClient |
|
protected static MongoMappingContext |
createMappingContext(ConnectionSources<com.mongodb.MongoClient, MongoConnectionSourceSettings> connectionSources, java.lang.Class... classes) |
|
protected static MongoMappingContext |
createMappingContext(org.springframework.core.env.PropertyResolver configuration, java.lang.Class... classes) |
|
protected static com.mongodb.MongoClient |
createMongoClient(org.springframework.core.env.PropertyResolver configuration, com.mongodb.MongoClientOptions$Builder mongoOptions, MongoMappingContext mappingContext) |
|
protected Session |
createSession(org.springframework.core.env.PropertyResolver connDetails) |
|
protected Session |
createStatelessSession(org.springframework.core.env.PropertyResolver connectionDetails) |
|
ConfigurableApplicationEventPublisher |
getApplicationEventPublisher() @return The ConfigurableApplicationEventPublisher instance used by this datastore |
|
AutoTimestampEventListener |
getAutoTimestampEventListener() |
|
org.bson.codecs.configuration.CodecRegistry |
getCodecRegistry() @return The org.bson.codecs.configuration.CodecRegistry |
|
com.mongodb.client.MongoCollection<org.bson.Document> |
getCollection(PersistentEntity entity) Obtain the raw com.mongodb.client.MongoCollection for the given entity |
|
java.lang.String |
getCollectionName(PersistentEntity entity) Gets the default collection name for the given entity |
|
ConnectionSources<com.mongodb.MongoClient, MongoConnectionSourceSettings> |
getConnectionSources() @return The ConnectionSources for this datastore |
|
java.lang.String |
getDatabaseName(PersistentEntity entity) |
|
MongoDatastore |
getDatastoreForTenantId(java.io.Serializable tenantId) |
|
java.lang.String |
getDefaultDatabase() @return The default database name |
|
javax.persistence.FlushModeType |
getDefaultFlushMode() @return The default flush mode |
|
MongoMappingContext |
getMappingContext() @return The mapping context |
|
com.mongodb.MongoClient |
getMongoClient() @return The com.mongodb.MongoClient instance |
|
MultiTenancyMode |
getMultiTenancyMode() |
|
PersistentEntityCodec |
getPersistentEntityCodec(PersistentEntity entity) Obtains a PersistentEntityCodec for the given entity |
|
PersistentEntityCodec |
getPersistentEntityCodec(java.lang.Class entityClass) Obtains a PersistentEntityCodec for the given entity |
|
TenantResolver |
getTenantResolver() |
|
org.springframework.transaction.PlatformTransactionManager |
getTransactionManager() @return The transaction manager |
|
protected MongoGormEnhancer |
initialize(MongoConnectionSourceSettings settings) Runs the initialization sequence |
|
protected void |
initializeIndices(PersistentEntity entity) Indexes any properties that are mapped with index:true |
|
boolean |
isSchemaless() |
|
void |
persistentEntityAdded(PersistentEntity entity) |
|
protected void |
registerEntity(PersistentEntity entity) |
|
protected void |
registerEventListeners(ConfigurableApplicationEventPublisher eventPublisher) |
|
void |
setCodecProviders(java.util.List<org.bson.codecs.configuration.CodecProvider> codecProviders) Sets any additional codec providers |
|
void |
setCodecRegistries(java.util.List<org.bson.codecs.configuration.CodecRegistry> codecRegistries) Sets any additional codec registries |
|
void |
setCodecs(java.util.List<org.bson.codecs.Codec<?>> codecs) Sets any additional codecs |
|
void |
setMessageSource(org.springframework.context.MessageSource messageSource) The message source used for validation messages |
<T1> |
T1 |
withNewSession(java.io.Serializable tenantId, groovy.lang.Closure<T1> callable) |
Methods inherited from class | Name |
---|---|
class AbstractDatastore |
setApplicationContext, connectStateless, hasCurrentSession, retrieveSession, retrieveSession, getApplicationEventPublisher, isSchemaless, withSession, getCurrentSession, getMappingContext, getApplicationContext, destroy, connect, connect, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Configures a new MongoDatastore for the given arguments
connectionSources
- The ConnectionSources to useeventPublisher
- The Spring ApplicationContextmappingContext
- The mapping contextConfigures a new MongoDatastore for the given arguments
connectionSources
- The ConnectionSources to useeventPublisher
- The Spring ApplicationContextclasses
- The persistent classesConfigures a new MongoDatastore for the given arguments
mongoClient
- The com.mongodb.MongoClient instanceeventPublisher
- The Spring ApplicationContextmappingContext
- The mapping contextConfigures a new MongoDatastore for the given arguments
mongoClient
- The com.mongodb.MongoClient instanceeventPublisher
- The Spring ApplicationContextclasses
- The persistent classesConfigures a new MongoDatastore for the given arguments
mongoClient
- The com.mongodb.MongoClient instanceclasses
- The persistent classesConfigures a new MongoDatastore for the given arguments
mongoClient
- The com.mongodb.MongoClient instanceclasses
- The persistent classesConfigures a new MongoDatastore for the given arguments
clientOptions
- The com.mongodb.MongoClientOptions instanceconfiguration
- The configurationeventPublisher
- The Spring ApplicationContextmappingContext
- The mapping contextConfigures a new MongoDatastore for the given arguments
clientOptions
- The com.mongodb.MongoClientOptions instanceconfiguration
- The configurationmappingContext
- The mapping contextConfigures a new MongoDatastore for the given arguments
configuration
- The configuration for the datastoreeventPublisher
- The Spring ApplicationContextmappingContext
- The mapping contextConfigures a new MongoDatastore for the given arguments
configuration
- The configuration for the datastoreeventPublisher
- The Spring ApplicationContextconnectionSourceFactory
- The connection source factory to useclasses
- The persistent classesConfigures a new MongoDatastore for the given arguments
configuration
- The configuration for the datastoreeventPublisher
- The Spring ApplicationContextclasses
- The persistent classesConfigures a new MongoDatastore for the given arguments
configuration
- The configuration for the datastoremappingContext
- The mapping contextConfigures a new MongoDatastore for the given arguments
configuration
- The configuration for the datastoreclasses
- The persistent classesConfigures a new MongoDatastore for the given arguments
configuration
- The configurationeventPublisher
- The event publisherclasses
- The persistent classesConfigures a new MongoDatastore for the given arguments
configuration
- The configurationclasses
- The persistent classesConfigures a new MongoDatastore for the given arguments
configuration
- The configurationmappingContext
- The MongoMappingContextConfigures a new MongoDatastore for the given arguments
mappingContext
- The MongoMappingContextConfigures a new MongoDatastore for the given arguments
classes
- The persistent classesBuilds the MongoDB index for this datastore
Creates the connection sources for an existing com.mongodb.MongoClient
mongoClient
- The com.mongodb.MongoClientconfiguration
- The configurationmappingContext
- The MongoMappingContext
Obtain the raw com.mongodb.client.MongoCollection for the given entity
entity
- The entityGets the default collection name for the given entity
entity
- The entity
Obtains a PersistentEntityCodec for the given entity
entity
- The entityObtains a PersistentEntityCodec for the given entity
entityClass
- The entity class
Runs the initialization sequence
Indexes any properties that are mapped with index:true
entity
- The entitySets any additional codec providers
codecProviders
- The org.bson.codecs.configuration.CodecProvider instancesSets any additional codec registries
codecRegistries
- The org.bson.codecs.configuration.CodecRegistry instancesSets any additional codecs
codecs
- The org.bson.codecs.Codec instancesThe message source used for validation messages
messageSource
- The message source