org.axonframework.mongo3.eventstore
Class DefaultMongoTemplate

java.lang.Object
  extended by org.axonframework.mongo3.common.AbstractMongoTemplate
      extended by org.axonframework.mongo3.eventstore.DefaultMongoTemplate
All Implemented Interfaces:
MongoTemplate

public class DefaultMongoTemplate
extends AbstractMongoTemplate
implements MongoTemplate

Default implementation for the MongoTemplate. This implementation requires access to the configured MongoClient object. You can influence the names of the collections used to store the events as well as the snapshot events.

Since:
2.0 (in incubator since 0.7)
Author:
Allard Buijze, Jettro Coenradie

Constructor Summary
DefaultMongoTemplate(com.mongodb.MongoClient mongoClient)
          Initializes the MongoTemplate using the given mongo for database access, using default database and collection names.
DefaultMongoTemplate(com.mongodb.MongoClient mongoClient, String databaseName, String domainEventsCollectionName, String snapshotEventsCollectionName)
          Creates a template connecting to given mongo instance, and loads events in the collection with given domainEventsCollectionName and snapshot events from snapshotEventsCollectionName, in a database with given databaseName.
 
Method Summary
 com.mongodb.client.MongoCollection<org.bson.Document> domainEventCollection()
          Returns a reference to the collection containing the domain events.
 com.mongodb.client.MongoCollection<org.bson.Document> snapshotEventCollection()
          Returns a reference to the collection containing the snapshot events.
 
Methods inherited from class org.axonframework.mongo3.common.AbstractMongoTemplate
database
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultMongoTemplate

public DefaultMongoTemplate(com.mongodb.MongoClient mongoClient)
Initializes the MongoTemplate using the given mongo for database access, using default database and collection names.

Database name:
Domain events collection name:
Snapshot events collection name:

Consider using DefaultMongoTemplate(com.mongodb.MongoClient, String, String, String) to provide different names for database and/or collections.

Parameters:
mongoClient - The actual connection to a MongoDB instance

DefaultMongoTemplate

public DefaultMongoTemplate(com.mongodb.MongoClient mongoClient,
                            String databaseName,
                            String domainEventsCollectionName,
                            String snapshotEventsCollectionName)
Creates a template connecting to given mongo instance, and loads events in the collection with given domainEventsCollectionName and snapshot events from snapshotEventsCollectionName, in a database with given databaseName. When not null, the given userName and password are used to authenticate against the database.

Parameters:
mongoClient - The Mongo instance configured to connect to the Mongo Server
databaseName - The name of the database containing the data
domainEventsCollectionName - The name of the collection containing domain events
snapshotEventsCollectionName - The name of the collection containing snapshot events
Method Detail

domainEventCollection

public com.mongodb.client.MongoCollection<org.bson.Document> domainEventCollection()
Returns a reference to the collection containing the domain events.

Specified by:
domainEventCollection in interface MongoTemplate
Returns:
MongoCollection containing the domain events

snapshotEventCollection

public com.mongodb.client.MongoCollection<org.bson.Document> snapshotEventCollection()
Returns a reference to the collection containing the snapshot events.

Specified by:
snapshotEventCollection in interface MongoTemplate
Returns:
MongoCollection containing the snapshot events


Copyright © 2010-2016. All Rights Reserved.