com.holonplatform.datastore.mongo.sync.internal

## Class DefaultMongoDatastore

- java.lang.Object
- - com.holonplatform.core.internal.datastore.AbstractDatastore<X>
  - - com.holonplatform.core.internal.datastore.AbstractInitializableDatastore<X>
    - - com.holonplatform.datastore.mongo.core.internal.datastore.AbstractMongoDatastore<SyncMongoDatastoreCommodityContext,com.mongodb.client.ClientSession,SyncMongoTransaction,com.mongodb.client.MongoDatabase>
      - - com.holonplatform.datastore.mongo.sync.internal.DefaultMongoDatastore

- All Implemented Interfaces:
    com.holonplatform.core.datastore.ConfigurableDatastore, com.holonplatform.core.datastore.DataContextBound, com.holonplatform.core.datastore.Datastore, com.holonplatform.core.datastore.DatastoreCommodityContext, com.holonplatform.core.datastore.DatastoreCommodityHandler, com.holonplatform.core.datastore.DatastoreCommodityRegistrar<SyncMongoDatastoreCommodityContext>, com.holonplatform.core.datastore.DatastoreExpressionResolverRegistrar, com.holonplatform.core.datastore.DatastoreOperations<com.holonplatform.core.datastore.Datastore.OperationResult,com.holonplatform.core.property.PropertyBox,com.holonplatform.core.datastore.bulk.BulkInsert,com.holonplatform.core.datastore.bulk.BulkUpdate,com.holonplatform.core.datastore.bulk.BulkDelete,com.holonplatform.core.query.Query>, com.holonplatform.core.datastore.transaction.Transactional, com.holonplatform.core.ExpressionResolver.ExpressionResolverHandler, com.holonplatform.core.ExpressionResolver.ExpressionResolverProvider, com.holonplatform.core.ExpressionResolver.ExpressionResolverSupport, MongoDatastoreCommodityContext<com.mongodb.client.MongoDatabase,com.mongodb.client.ClientSession>, MongoContext<com.mongodb.client.ClientSession>, MongoOperationContext<com.mongodb.client.MongoDatabase,com.mongodb.client.ClientSession>, MongoDatabaseHandler<com.mongodb.client.MongoDatabase>, SyncMongoDatastoreCommodityContext, MongoDatastore, Serializable

      public class DefaultMongoDatastore
      extends com.holonplatform.datastore.mongo.core.internal.datastore.AbstractMongoDatastore<SyncMongoDatastoreCommodityContext,com.mongodb.client.ClientSession,SyncMongoTransaction,com.mongodb.client.MongoDatabase>
      implements MongoDatastore, SyncMongoDatastoreCommodityContext

  Default `MongoDatastore` implementation.
  Since:
    5.2.0
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `DefaultMongoDatastore.DefaultBuilder`

    - ### Nested classes/interfaces inherited from class com.holonplatform.datastore.mongo.core.internal.datastore.AbstractMongoDatastore

      `com.holonplatform.datastore.mongo.core.internal.datastore.AbstractMongoDatastore.AbstractBuilder<MDB,CX extends com.holonplatform.core.datastore.DatastoreCommodityContext,S extends com.mongodb.session.ClientSession,TX extends MongoTransaction<S>,I extends com.holonplatform.datastore.mongo.core.internal.datastore.AbstractMongoDatastore<CX,S,TX,MDB>,D extends com.holonplatform.core.datastore.DatastoreOperations,B extends MongoDatastoreBuilder<D,S,TX,B>>`

    - ### Nested classes/interfaces inherited from interface com.holonplatform.datastore.mongo.sync.MongoDatastore

      `MongoDatastore.Builder`

    - ### Nested classes/interfaces inherited from interface com.holonplatform.core.datastore.Datastore

      `com.holonplatform.core.datastore.Datastore.OperationResult, com.holonplatform.core.datastore.Datastore.OperationType`

    - ### Nested classes/interfaces inherited from interface com.holonplatform.core.datastore.DatastoreOperations

      `com.holonplatform.core.datastore.DatastoreOperations.WriteOption`

    - ### Nested classes/interfaces inherited from interface com.holonplatform.core.datastore.DatastoreCommodityContext

      `com.holonplatform.core.datastore.DatastoreCommodityContext.CommodityConfigurationException, com.holonplatform.core.datastore.DatastoreCommodityContext.CommodityNotAvailableException`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultMongoDatastore()` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `com.mongodb.client.MongoClient` | `getClient()` Get the MongoDB client.
    `Optional<com.mongodb.client.ClientSession>` | `getClientSession()` Get the current client session, if available.
    `org.bson.codecs.configuration.CodecRegistry` | `getDatabaseCodecRegistry()` Get the `CodecRegistry` bound to the current database.
    `boolean` | `isAsync()` Gets whether the MongoDB driver in use is asynchronous.
    `void` | `setClient(com.mongodb.client.MongoClient client)` Set the MongoDB client to use.
    `String` | `toString()`
    `<R> R` | `withDatabase(MongoDatabaseOperation<com.mongodb.client.MongoDatabase,R> operation)` Execute given `MongoDatabaseOperation` using a managed MongoDatabase.
    `<R> R` | `withTransaction(com.holonplatform.core.datastore.transaction.TransactionalOperation<R> operation, com.holonplatform.core.datastore.transaction.TransactionConfiguration transactionConfiguration)`

    - ### Methods inherited from class com.holonplatform.datastore.mongo.core.internal.datastore.AbstractMongoDatastore

      `getDatabaseName, getDefaultEnumCodecStrategy, getDefaultReadConcern, getDefaultReadPreference, getDefaultWriteConcern, getDocumentIdResolver, setDatabaseName, setDefaultReadConcern, setDefaultReadPreference, setDefaultWriteConcern, setDocumentIdResolver, setEnumCodecStrategy, setTransactionFactory, trace`

    - ### Methods inherited from class com.holonplatform.core.internal.datastore.AbstractInitializableDatastore

      `getInitializationClassLoader, initialize, isInitialized, setInitializationClassLoader`

    - ### Methods inherited from class com.holonplatform.core.internal.datastore.AbstractDatastore

      `addExpressionResolver, create, getAvailableCommodities, getCommodityFactoryType, getDataContextId, getExpressionResolvers, getExpressionResolverType, isTraceEnabled, registerCommodity, removeExpressionResolver, resolve, setDataContextId, setTraceEnabled`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface com.holonplatform.datastore.mongo.sync.MongoDatastore

      `builder`

    - ### Methods inherited from interface com.holonplatform.core.datastore.Datastore

      `bulkDelete, bulkInsert, bulkUpdate, delete, insert, isTransactional, query, query, refresh, requireTransactional, save, update`

    - ### Methods inherited from interface com.holonplatform.core.ExpressionResolver.ExpressionResolverSupport

      `addExpressionResolver, addExpressionResolvers, removeExpressionResolver`

    - ### Methods inherited from interface com.holonplatform.core.datastore.DataContextBound

      `getDataContextId`

    - ### Methods inherited from interface com.holonplatform.core.datastore.DatastoreCommodityRegistrar

      `getCommodityFactoryType, registerCommodity`

    - ### Methods inherited from interface com.holonplatform.core.datastore.transaction.Transactional

      `withTransaction, withTransaction, withTransaction`

    - ### Methods inherited from interface com.holonplatform.datastore.mongo.core.config.MongoDatastoreCommodityContext

      `getDatabaseName`

    - ### Methods inherited from interface com.holonplatform.datastore.mongo.core.context.MongoContext

      `getDefaultEnumCodecStrategy, getDefaultReadConcern, getDefaultReadPreference, getDefaultWriteConcern, getDocumentIdResolver, toJson, toJson, toJson, trace, trace, trace, trace`

    - ### Methods inherited from interface com.holonplatform.core.ExpressionResolver.ExpressionResolverProvider

      `getExpressionResolvers`

    - ### Methods inherited from interface com.holonplatform.datastore.mongo.core.MongoDatabaseHandler

      `withDatabase`

    - ### Methods inherited from interface com.holonplatform.core.datastore.DatastoreCommodityHandler

      `create, getAvailableCommodities, hasCommodity`

- - ### Constructor Detail

    - #### DefaultMongoDatastore

          public DefaultMongoDatastore()

      Constructor.

  - ### Method Detail

    - #### setClient

          public void setClient(com.mongodb.client.MongoClient client)

      Set the MongoDB client to use.
      Parameters:
        `client` - the client to set

    - #### getClient

          public com.mongodb.client.MongoClient getClient()

      Description copied from interface: `SyncMongoDatastoreCommodityContext`
      Get the MongoDB client.
      Specified by:
        `getClient` in interface `SyncMongoDatastoreCommodityContext`
      Returns:
        the MongoDB client

    - #### isAsync

          public boolean isAsync()

      Description copied from interface: `MongoOperationContext`
      Gets whether the MongoDB driver in use is asynchronous.
      Specified by:
        `isAsync` in interface `MongoOperationContext<com.mongodb.client.MongoDatabase,com.mongodb.client.ClientSession>`
      Returns:
        `true` if in asynchronous mode, `false` if in synchronous mode

    - #### getClientSession

          public Optional<com.mongodb.client.ClientSession> getClientSession()

      Description copied from interface: `MongoContext`
      Get the current client session, if available.
      Specified by:
        `getClientSession` in interface `MongoContext<com.mongodb.client.ClientSession>`
      Returns:
        Optional client session

    - #### getDatabaseCodecRegistry

          public org.bson.codecs.configuration.CodecRegistry getDatabaseCodecRegistry()

      Description copied from interface: `MongoContext`
      Get the `CodecRegistry` bound to the current database.
      Specified by:
        `getDatabaseCodecRegistry` in interface `MongoContext<com.mongodb.client.ClientSession>`
      Returns:
        Database `CodecRegistry`

    - #### withDatabase

          public <R> R withDatabase(MongoDatabaseOperation<com.mongodb.client.MongoDatabase,R> operation)

      Description copied from interface: `MongoDatabaseHandler`
      Execute given `MongoDatabaseOperation` using a managed MongoDatabase.
      Specified by:
        `withDatabase` in interface `MongoDatabaseHandler<com.mongodb.client.MongoDatabase>`
      Type Parameters:
        `R` - Operation result type
      Parameters:
        `operation` - Operation to execute (not null)
      Returns:
        Operation result

    - #### withTransaction

          public <R> R withTransaction(com.holonplatform.core.datastore.transaction.TransactionalOperation<R> operation,
                                       com.holonplatform.core.datastore.transaction.TransactionConfiguration transactionConfiguration)

      Specified by:
        `withTransaction` in interface `com.holonplatform.core.datastore.transaction.Transactional`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `com.holonplatform.core.internal.datastore.AbstractDatastore<SyncMongoDatastoreCommodityContext>`

Copyright © 2019 The Holon Platform. All rights reserved.