if (username != null) {
mongoDb.authenticate(username, password);
}
if (tableDefs == null || tableDefs.length == 0) {
return new MongoDbDataContext(mongoDb);
}
return new MongoDbDataContext(mongoDb, tableDefs);
} catch (Exception e) {
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
}
throw new IllegalStateException(e);