Class DefaultMongoTemplate
java.lang.Object
org.axonframework.extensions.mongo.AbstractMongoTemplate
org.axonframework.extensions.mongo.DefaultMongoTemplate
- All Implemented Interfaces:
MongoTemplate
MongoTemplate instance giving direct access to the saga collection via a given MongoClient instance. Will use the
default name for the collection, when none is set.
The default is sagas for the sagas.
- Since:
- 3.0
- Author:
- Allard Buijze
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class to instantiate aDefaultMongoTemplate. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInstantiate aDefaultMongoTemplatebased on the fields contained in theDefaultMongoTemplate.Builder. -
Method Summary
Modifier and TypeMethodDescriptionstatic DefaultMongoTemplate.Builderbuilder()Instantiate a Builder to be able to create aDefaultMongoTemplate.com.mongodb.client.MongoCollection<org.bson.Document> Returns a reference to the collection containing the saga instances.withSagasCollection(String sagasCollectionName) Overwrites thesagasCollectionNameto use as the collection name for Sagas.Methods inherited from class org.axonframework.extensions.mongo.AbstractMongoTemplate
database
-
Constructor Details
-
DefaultMongoTemplate
Instantiate aDefaultMongoTemplatebased on the fields contained in theDefaultMongoTemplate.Builder.Will assert that the
MongoDatabaseis notnull, and will throw anAxonConfigurationExceptionif any of them isnull.- Parameters:
builder- theDefaultMongoTemplate.Builderused to instantiate aDefaultMongoTemplateinstance
-
-
Method Details
-
builder
Instantiate a Builder to be able to create aDefaultMongoTemplate.The
sagasCollectionNameis defaulted tosagas.The
MongoDatabaseis a hard requirement and as such should be provided. Can either be provided directly, or by setting aMongoClient. When choosing the latter approach, the MongoDatabase name can be specified by using theDefaultMongoTemplate.Builder.mongoDatabase(MongoClient, String)function. Otherwise, the database name defaults toAbstractMongoTemplate.Builder#DEFAULT_AXONFRAMEWORK_DATABASE- Returns:
- a Builder to be able to create a
DefaultMongoTemplate
-
withSagasCollection
Overwrites thesagasCollectionNameto use as the collection name for Sagas.- Parameters:
sagasCollectionName- aStringspecifying the collection name for Sagas- Returns:
- a new
DefaultMongoTemplatewith the givensagasCollectionNameset.
-
sagaCollection
public com.mongodb.client.MongoCollection<org.bson.Document> sagaCollection()Description copied from interface:MongoTemplateReturns a reference to the collection containing the saga instances.- Specified by:
sagaCollectionin interfaceMongoTemplate- Returns:
- MongoCollection containing the sagas
-