Class AbstractMongoTemplate.Builder

java.lang.Object
org.axonframework.extensions.mongo.AbstractMongoTemplate.Builder
Direct Known Subclasses:
DefaultMongoTemplate.Builder
Enclosing class:
AbstractMongoTemplate

public abstract static class AbstractMongoTemplate.Builder extends Object
Abstract Builder class to instantiate a AbstractMongoTemplate.

The MongoDatabase is a hard requirement and as such should be provided. Can either be provided directly, or by setting a MongoClient. When choosing the latter approach, the MongoDatabase name can be specified by using the mongoDatabase(MongoClient, String) function. Otherwise, the database name defaults to DEFAULT_AXONFRAMEWORK_DATABASE

  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • mongoDatabase

      public AbstractMongoTemplate.Builder mongoDatabase(com.mongodb.client.MongoClient mongoClient)
      Sets the MongoDatabase by means of providing a MongoClient. The MongoCluster.getDatabase(String) function is in turn used to retrieve the MongoDatabase, using DEFAULT_AXONFRAMEWORK_DATABASE as the database name.
      Parameters:
      mongoClient - the MongoClient used to retrieve a MongoDatabase from
      Returns:
      the current Builder instance, for fluent interfacing
    • mongoDatabase

      public AbstractMongoTemplate.Builder mongoDatabase(com.mongodb.client.MongoClient mongoClient, String databaseName)
      Sets the MongoDatabase by means of providing a MongoClient. The MongoCluster.getDatabase(String) function is in turn used to retrieve the MongoDatabase using databaseName as the database name.
      Parameters:
      mongoClient - the MongoClient used to retrieve a MongoDatabase from
      databaseName - a String denoting the name of the MongoDatabase
      Returns:
      the current Builder instance, for fluent interfacing
    • mongoDatabase

      public AbstractMongoTemplate.Builder mongoDatabase(com.mongodb.client.MongoDatabase mongoDatabase)
      Sets the MongoDatabase used by this template to connect to a Mongo instance.
      Parameters:
      mongoDatabase - the MongoDatabase used by this template to connect to a Mongo instance
      Returns:
      the current Builder instance, for fluent interfacing
    • validate

      protected void validate() throws AxonConfigurationException
      Validates whether the fields contained in this Builder are set accordingly.
      Throws:
      AxonConfigurationException - if one field is asserted to be incorrect according to the Builder's specifications