try {
if (uri == null) {
addError("Please set a non-null MongoDB URI.");
return;
}
MongoURI mongoURI = new MongoURI(uri);
String database = mongoURI.getDatabase();
String collection = mongoURI.getCollection();
if (database == null || collection == null) {
addError("Error connecting to MongoDB URI: " + uri + " must contain a database and a collection."
+ " E.g. mongodb://localhost/database.collection");
return;
}
mongo = new Mongo(mongoURI);
DB db = mongo.getDB(database);
String username = mongoURI.getUsername();
char[] password = mongoURI.getPassword();
if (username != null && password != null)
db.authenticate(username, password);
eventsCollection = db.getCollection(collection);
super.start();
} catch (Exception exception) {