|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.axonframework.eventstore.mongo.MongoFactory
public class MongoFactory
Factory bean for a Mongo instance class. This factory is required since we want to support the most basic setup as well as a more advanced setup. The most basic setup makes use of only one instance of Mongo. This scenario is not really suitable for a production environment, but it does work for a simple test environment.
The factory supports two environments:ServerAddress instances becomes mandatory.IllegalStateException is
thrown. Be warned, it is better to provide multiple servers in case of a Replica Set.
To configure a Mongo that fits your purpose, you can use two other configuration options. You can provide a
WriteConcern and a MongoOptions object.
The write concern is important in relation to the environment. In a single instance context, the SAFE WriteConcern is
by default used. For a replica set environment, by default the REPLICA_SAFE is used.
Configuring the Mongo instance thread pool can be done by providing a MongoOptions. To make this easier,
a factory is provided. The MongoOptionsFactory facilitates creating such an object. One good reason to
provide a MongoOptions object is to increase the number of connections to the actual mongo databasel
| Constructor Summary | |
|---|---|
MongoFactory()
Default constructor that configures the factory to create test context Mongo instances. |
|
MongoFactory(List<com.mongodb.ServerAddress> mongoAddresses)
Constructor creating defaults for WriteConcern.REPLICA_SAFE and default MongoOptions |
|
MongoFactory(List<com.mongodb.ServerAddress> mongoAddresses,
com.mongodb.MongoOptions mongoOptions,
com.mongodb.WriteConcern writeConcern)
Constructor that accepts addresses, options and the default write concern. |
|
| Method Summary | |
|---|---|
com.mongodb.Mongo |
createMongoInstance()
Creates a mongo instance based on the provided configuration. |
void |
setMongoAddresses(List<com.mongodb.ServerAddress> mongoAddresses)
Provide a list of ServerAddress objects to use for locating the Mongo replica set. |
void |
setMongoOptions(com.mongodb.MongoOptions mongoOptions)
Provide an instance of MongoOptions to be used for the connections. |
void |
setSingleInstanceContext(boolean testContext)
Sets the singleInstanceContext, provide true if you want the test context and false if you want the production context. |
void |
setWriteConcern(com.mongodb.WriteConcern writeConcern)
Provided a write concern to be used by the mongo instance. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MongoFactory()
public MongoFactory(List<com.mongodb.ServerAddress> mongoAddresses)
mongoAddresses - List containing the address of the servers to use
public MongoFactory(List<com.mongodb.ServerAddress> mongoAddresses,
com.mongodb.MongoOptions mongoOptions,
com.mongodb.WriteConcern writeConcern)
mongoAddresses - List of server addresses to configure the Mongo instance with.mongoOptions - MongoOptions instance to configure the Mongo instance withwriteConcern - WriteConcern to configure for the connection to the Mongo instance| Method Detail |
|---|
public void setMongoAddresses(List<com.mongodb.ServerAddress> mongoAddresses)
mongoAddresses - List of ServerAddress instancespublic void setMongoOptions(com.mongodb.MongoOptions mongoOptions)
mongoOptions - MongoOptions to overrule the defaultpublic void setSingleInstanceContext(boolean testContext)
testContext - Boolean indicating the context, true for test and false for production.public void setWriteConcern(com.mongodb.WriteConcern writeConcern)
writeConcern - WriteConcern to use for the connectionspublic com.mongodb.Mongo createMongoInstance()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||