org.axonframework.eventstore.mongo
Class DefaultMongoTemplate

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

public class DefaultMongoTemplate
extends AuthenticatingMongoTemplate
implements MongoTemplate

Default implementation for the MongoTemplate. This implementation requires access to the configured Mongo 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.Mongo mongo)
          Initializes the MongoTemplate using the given mongoDb for database access, using default database and collection names.
DefaultMongoTemplate(com.mongodb.Mongo mongo, String databaseName, String domainEventsCollectionName, String snapshotEventsCollectionName, String userName, char[] password)
          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.
DefaultMongoTemplate(com.mongodb.Mongo mongo, String databaseName, String domainEventsCollectionName, String snapshotEventsCollectionName, String authenticationDatabase, String userName, char[] password)
          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.DBCollection domainEventCollection()
          Returns a reference to the collection containing the domain events.
 com.mongodb.DBCollection snapshotEventCollection()
          Returns a reference to the collection containing the snapshot events.
 
Methods inherited from class org.axonframework.common.mongo.AuthenticatingMongoTemplate
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.Mongo mongo)
Initializes the MongoTemplate using the given mongoDb for database access, using default database and collection names.

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

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

Parameters:
mongo - The actual connection to a MongoDB instance

DefaultMongoTemplate

public DefaultMongoTemplate(com.mongodb.Mongo mongo,
                            String databaseName,
                            String domainEventsCollectionName,
                            String snapshotEventsCollectionName,
                            String userName,
                            char[] password)
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:
mongo - 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
userName - The username to authenticate with. Use null to skip authentication
password - The password to authenticate with. Use null to skip authentication

DefaultMongoTemplate

public DefaultMongoTemplate(com.mongodb.Mongo mongo,
                            String databaseName,
                            String domainEventsCollectionName,
                            String snapshotEventsCollectionName,
                            String authenticationDatabase,
                            String userName,
                            char[] password)
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:
mongo - 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
authenticationDatabase - The name of the database to authenticate to
userName - The username to authenticate with. Use null to skip authentication
password - The password to authenticate with. Use null to skip authentication
Method Detail

domainEventCollection

public com.mongodb.DBCollection domainEventCollection()
Returns a reference to the collection containing the domain events.

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

snapshotEventCollection

public com.mongodb.DBCollection snapshotEventCollection()
Returns a reference to the collection containing the snapshot events.

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


Copyright © 2010-2016. All Rights Reserved.