public class MongoDatastore extends AbstractDatastore implements MappingContextListener, java.io.Closeable, MultiTenantCapableDatastore, MultipleConnectionSourceCapableDatastore, StatelessDatastore, TransactionCapableDatastore
A Datastore implementation for the Mongo document store.
Modifiers | Name | Description |
---|---|---|
class |
MongoDatastore.PersistentEntityCodeRegistry |
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.client.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.client.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 |
Fields inherited from class | Fields |
---|---|
class AbstractDatastore |
LOG, applicationContext, cacheAdapterRepository, connectionDetails, mappingContext, serviceRegistry |
Constructor and description |
---|
MongoDatastore
(ConnectionSources<com.mongodb.client.MongoClient, MongoConnectionSourceSettings> connectionSources, MongoMappingContext mappingContext, ConfigurableApplicationEventPublisher eventPublisher) Configures a new MongoDatastore for the given arguments |
MongoDatastore
(ConnectionSources<com.mongodb.client.MongoClient, MongoConnectionSourceSettings> connectionSources, ConfigurableApplicationEventPublisher eventPublisher, java.lang.Class classes) Configures a new MongoDatastore for the given arguments |
MongoDatastore
(com.mongodb.client.MongoClient mongoClient, org.springframework.core.env.PropertyResolver configuration, MongoMappingContext mappingContext, ConfigurableApplicationEventPublisher eventPublisher) Configures a new MongoDatastore for the given arguments |
MongoDatastore
(com.mongodb.client.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.client.MongoClient mongoClient, org.springframework.core.env.PropertyResolver configuration, ConfigurableApplicationEventPublisher eventPublisher, java.lang.Package packages) Configures a new MongoDatastore for the given arguments |
MongoDatastore
(com.mongodb.client.MongoClient mongoClient, org.springframework.core.env.PropertyResolver configuration, java.lang.Class classes) Configures a new MongoDatastore for the given arguments |
MongoDatastore
(com.mongodb.client.MongoClient mongoClient, org.springframework.core.env.PropertyResolver configuration, java.lang.Package packages) Configures a new MongoDatastore for the given arguments |
MongoDatastore
(com.mongodb.client.MongoClient mongoClient, java.lang.Class classes) Configures a new MongoDatastore for the given arguments |
MongoDatastore
(com.mongodb.MongoClientSettings$Builder clientOptions, org.springframework.core.env.PropertyResolver configuration, MongoMappingContext mappingContext, ConfigurableApplicationEventPublisher eventPublisher) Configures a new MongoDatastore for the given arguments |
MongoDatastore
(com.mongodb.MongoClientSettings$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) Creates a MongoDatastore with the given configuration |
MongoDatastore
(java.util.Map<java.lang.String, java.lang.Object> configuration, MongoMappingContext mappingContext) |
MongoDatastore
(MongoMappingContext mappingContext) Configures a new MongoDatastore for the given arguments |
MongoDatastore
(java.lang.Class classes) Configures a new MongoDatastore for the given arguments |
MongoDatastore
(java.lang.Package packagesToScan) Construct a Mongo datastore scanning the given packages |
MongoDatastore
(java.lang.Package packageToScan) Construct a Mongo datastore scanning the given package |
MongoDatastore
(org.springframework.core.env.PropertyResolver configuration, java.lang.Package packagesToScan) Construct a Mongo datastore scanning the given packages |
MongoDatastore
(java.util.Map<java.lang.String, java.lang.Object> configuration, java.lang.Package packagesToScan) Construct a Mongo datastore scanning the given packages |
MongoDatastore
(org.springframework.core.env.PropertyResolver configuration, ConfigurableApplicationEventPublisher eventPublisher, java.lang.Package packagesToScan) Construct a Mongo datastore scanning the given packages |
Type Params | Return Type | Name and description |
---|---|---|
|
public void |
buildIndex() Builds the MongoDB index for this datastore |
|
public void |
close() |
|
private static void |
configureValidationRegistry(MongoConnectionSourceSettings settings, MongoMappingContext mongoMappingContext) |
|
private static void |
configureValidatorRegistry(MongoConnectionSourceSettings settings, MongoMappingContext mongoMappingContext, org.springframework.context.MessageSource messageSource) |
|
private MongoDatastore |
createChildDatastore(MongoMappingContext mappingContext, ConfigurableApplicationEventPublisher eventPublisher, MongoDatastore parent, SingletonConnectionSources<com.mongodb.client.MongoClient, MongoConnectionSourceSettings> singletonConnectionSources) |
|
protected static ConnectionSources<com.mongodb.client.MongoClient, MongoConnectionSourceSettings> |
createDefaultConnectionSources(com.mongodb.client.MongoClient mongoClient, org.springframework.core.env.PropertyResolver configuration, MongoMappingContext mappingContext) Creates the connection sources for an existing com.mongodb.client.MongoClient |
|
protected static MongoMappingContext |
createMappingContext(ConnectionSources<com.mongodb.client.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.client.MongoClient |
createMongoClient(org.springframework.core.env.PropertyResolver configuration, com.mongodb.MongoClientSettings$Builder mongoOptions, MongoMappingContext mappingContext) |
|
protected Session |
createSession(org.springframework.core.env.PropertyResolver connDetails) |
|
protected Session |
createStatelessSession(org.springframework.core.env.PropertyResolver connectionDetails) |
|
public ConfigurableApplicationEventPublisher |
getApplicationEventPublisher()
|
|
public AutoTimestampEventListener |
getAutoTimestampEventListener() |
|
public org.bson.codecs.configuration.CodecRegistry |
getCodecRegistry()
|
|
public com.mongodb.client.MongoCollection<org.bson.Document> |
getCollection(PersistentEntity entity) Obtain the raw com.mongodb.client.MongoCollection for the given entity |
|
public java.lang.String |
getCollectionName(PersistentEntity entity) Gets the default collection name for the given entity |
|
public ConnectionSources<com.mongodb.client.MongoClient, MongoConnectionSourceSettings> |
getConnectionSources()
|
|
public java.lang.String |
getDatabaseName(PersistentEntity entity) |
|
public MongoDatastore |
getDatastoreForConnection(java.lang.String connectionName) |
|
public Datastore |
getDatastoreForConnection(java.lang.String connectionName) |
<D> |
private MongoDatastore |
getDatastoreForQualifier(java.lang.Class<D> cls, java.lang.String qualifier) |
|
public MongoDatastore |
getDatastoreForTenantId(java.io.Serializable tenantId) |
|
public java.lang.String |
getDefaultDatabase()
|
|
public javax.persistence.FlushModeType |
getDefaultFlushMode()
|
<D> |
protected GormInstanceApi<D> |
getInstanceApi(java.lang.Class<D> cls, java.lang.String qualifier) |
|
public MongoMappingContext |
getMappingContext()
|
|
public com.mongodb.client.MongoClient |
getMongoClient()
|
|
java.lang.String |
getMongoFieldNameForProperty(PersistentProperty<MongoAttribute> property) |
|
public MultiTenancyMode |
getMultiTenancyMode() |
|
public PersistentEntityCodec |
getPersistentEntityCodec(PersistentEntity entity) Obtains a PersistentEntityCodec for the given entity |
|
public PersistentEntityCodec |
getPersistentEntityCodec(java.lang.Class entityClass) Obtains a PersistentEntityCodec for the given entity |
<D> |
protected MongoStaticApi<D> |
getStaticApi(java.lang.Class<D> cls, java.lang.String qualifier) |
|
public TenantResolver |
getTenantResolver() |
|
public org.springframework.transaction.PlatformTransactionManager |
getTransactionManager()
|
<D> |
protected GormValidationApi<D> |
getValidationApi(java.lang.Class<D> cls, java.lang.String qualifier) |
|
protected MongoGormEnhancer |
initialize(MongoConnectionSourceSettings settings) |
|
protected MongoGormEnhancer |
initialize(MongoConnectionSourceSettings settings) Runs the initialization sequence |
|
protected void |
initializeIndices(PersistentEntity entity) Indexes any properties that are mapped with index:true |
|
public boolean |
isSchemaless() |
|
public void |
newConnectionSource(ConnectionSource<com.mongodb.client.MongoClient, MongoConnectionSourceSettings> connectionSource) |
|
public void |
persistentEntityAdded(PersistentEntity entity) |
|
public void |
persistentEntityAdded(PersistentEntity entity) |
|
protected void |
registerAllEntitiesWithEnhancer() |
|
protected void |
registerEntity(PersistentEntity entity) |
|
protected void |
registerEventListeners(ConfigurableApplicationEventPublisher eventPublisher) |
|
public java.io.Serializable |
resolveTenantIdentifier() |
|
public java.lang.Iterable<java.io.Serializable> |
resolveTenantIds() |
|
public void |
setCodecProviders(java.util.List<org.bson.codecs.configuration.CodecProvider> codecProviders) Sets any additional codec providers |
|
public void |
setCodecRegistries(java.util.List<org.bson.codecs.configuration.CodecRegistry> codecRegistries) Sets any additional codec registries |
|
public void |
setCodecs(java.util.List<org.bson.codecs.Codec<?>> codecs) Sets any additional codecs |
|
public void |
setMessageSource(org.springframework.context.MessageSource messageSource) The message source used for validation messages |
<T1> |
public T1 |
withNewSession(java.io.Serializable tenantId, groovy.lang.Closure<T1> callable) |
Methods inherited from class | Name |
---|---|
class AbstractDatastore |
connect, connect, connectStateless, createSession, createStatelessSession, destroy, doInSession, getApplicationContext, getApplicationEventPublisher, getCurrentSession, getMappingContext, getService, getServices, hasCurrentSession, initializeConverters, isIndexed, isSchemaless, mapToPropertyResolver, publishSessionCreationEvent, retrieveSession, retrieveSession, setApplicationContext, withSession |
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.client.MongoClient instanceeventPublisher
- The Spring ApplicationContextmappingContext
- The mapping contextConfigures a new MongoDatastore for the given arguments
mongoClient
- The com.mongodb.client.MongoClient instanceeventPublisher
- The Spring ApplicationContextclasses
- The persistent classesConfigures a new MongoDatastore for the given arguments
mongoClient
- The com.mongodb.client.MongoClient instanceeventPublisher
- The Spring ApplicationContextpackages
- The packages to scanConfigures a new MongoDatastore for the given arguments
mongoClient
- The com.mongodb.client.MongoClient instanceclasses
- The persistent classesConfigures a new MongoDatastore for the given arguments
mongoClient
- The com.mongodb.client.MongoClient instancepackages
- The packages to scanConfigures a new MongoDatastore for the given arguments
mongoClient
- The com.mongodb.client.MongoClient instanceclasses
- The persistent classesConfigures a new MongoDatastore for the given arguments
clientOptions
- The com.mongodb.MongoClientSettings instanceconfiguration
- The configurationeventPublisher
- The Spring ApplicationContextmappingContext
- The mapping contextConfigures a new MongoDatastore for the given arguments
clientOptions
- The com.mongodb.MongoClientSettings 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 classesCreates a MongoDatastore with the given configuration
configuration
- The configurationConfigures a new MongoDatastore for the given arguments
mappingContext
- The MongoMappingContextConfigures a new MongoDatastore for the given arguments
classes
- The persistent classesConstruct a Mongo datastore scanning the given packages
packagesToScan
- The packages to scanConstruct a Mongo datastore scanning the given package
packageToScan
- The packages to scanConstruct a Mongo datastore scanning the given packages
configuration
- The configurationpackagesToScan
- The packages to scanConstruct a Mongo datastore scanning the given packages
configuration
- The configurationpackagesToScan
- The packages to scanConstruct a Mongo datastore scanning the given packages
configuration
- The configurationeventPublisher
- The event publisherpackagesToScan
- The packages to scanBuilds the MongoDB index for this datastore
Creates the connection sources for an existing com.mongodb.client.MongoClient
mongoClient
- The com.mongodb.client.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