Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit abf5079

Browse files
author
lstolowski
committed
Merge branch 'master' of https://github.com/roded/mongobee into roded-master
# Conflicts: # src/main/java/com/github/mongobee/Mongobee.java # src/main/java/com/github/mongobee/dao/ChangeEntryDao.java
2 parents 81176bc + f73e3dc commit abf5079

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

src/main/java/com/github/mongobee/Mongobee.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,4 +328,12 @@ public Mongobee setJongo(Jongo jongo) {
328328
return this;
329329
}
330330

331+
332+
/**
333+
* Closes the Mongo instance used by Mongobee.
334+
* This will close either the connection Mongobee was initiated with or that which was internally created.
335+
*/
336+
public void close() {
337+
dao.close();
338+
}
331339
}

src/main/java/com/github/mongobee/dao/ChangeEntryDao.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class ChangeEntryDao {
2727
private static final Logger logger = LoggerFactory.getLogger("Mongobee dao");
2828

2929
private DB db;
30+
private Mongo mongo;
3031
private ChangeEntryIndexDao indexDao = new ChangeEntryIndexDao();
3132

3233
private LockDao lockDao = new LockDao();
@@ -39,6 +40,7 @@ public DB connectMongoDb(Mongo mongo, String dbName) throws MongobeeConfiguratio
3940
if (!hasText(dbName)) {
4041
throw new MongobeeConfigurationException("DB name is not set. Should be defined in MongoDB URI or via setter");
4142
} else {
43+
this.mongo = mongo;
4244
db = mongo.getDB(dbName);
4345
ensureChangeLogCollectionIndex(db.getCollection(CHANGELOG_COLLECTION));
4446
initializeLock();
@@ -114,6 +116,10 @@ private void ensureChangeLogCollectionIndex(DBCollection collection) {
114116

115117
}
116118

119+
public void close() {
120+
this.mongo.close();
121+
}
122+
117123
private void initializeLock() {
118124
lockDao.intitializeLock(db);
119125
}

0 commit comments

Comments
 (0)