Class AbstractMongoTemplate.Builder
java.lang.Object
org.axonframework.extensions.mongo.AbstractMongoTemplate.Builder
- Direct Known Subclasses:
DefaultMongoTemplate.Builder
- Enclosing class:
AbstractMongoTemplate
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionmongoDatabase(com.mongodb.client.MongoClient mongoClient) Sets theMongoDatabaseby means of providing aMongoClient.mongoDatabase(com.mongodb.client.MongoClient mongoClient, String databaseName) Sets theMongoDatabaseby means of providing aMongoClient.mongoDatabase(com.mongodb.client.MongoDatabase mongoDatabase) Sets theMongoDatabaseused by this template to connect to a Mongo instance.protected voidvalidate()Validates whether the fields contained in this Builder are set accordingly.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
mongoDatabase
Sets theMongoDatabaseby means of providing aMongoClient. TheMongoCluster.getDatabase(String)function is in turn used to retrieve the MongoDatabase, usingDEFAULT_AXONFRAMEWORK_DATABASEas the database name.- Parameters:
mongoClient- theMongoClientused to retrieve aMongoDatabasefrom- Returns:
- the current Builder instance, for fluent interfacing
-
mongoDatabase
public AbstractMongoTemplate.Builder mongoDatabase(com.mongodb.client.MongoClient mongoClient, String databaseName) Sets theMongoDatabaseby means of providing aMongoClient. TheMongoCluster.getDatabase(String)function is in turn used to retrieve the MongoDatabase usingdatabaseNameas the database name.- Parameters:
mongoClient- theMongoClientused to retrieve aMongoDatabasefromdatabaseName- aStringdenoting the name of theMongoDatabase- Returns:
- the current Builder instance, for fluent interfacing
-
mongoDatabase
Sets theMongoDatabaseused by this template to connect to a Mongo instance.- Parameters:
mongoDatabase- theMongoDatabaseused by this template to connect to a Mongo instance- Returns:
- the current Builder instance, for fluent interfacing
-
validate
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
-