11package com .github .mongobee ;
22
3- import static com .mongodb .ServerAddress .defaultHost ;
4- import static com .mongodb .ServerAddress .defaultPort ;
5- import static org .springframework .util .StringUtils .hasText ;
6-
7- import java .lang .reflect .InvocationTargetException ;
8- import java .lang .reflect .Method ;
9- import java .util .List ;
10-
11- import org .jongo .Jongo ;
12- import org .slf4j .Logger ;
13- import org .slf4j .LoggerFactory ;
14- import org .springframework .beans .factory .InitializingBean ;
15- import org .springframework .core .env .Environment ;
16- import org .springframework .data .mongodb .core .MongoTemplate ;
17-
183import com .github .mongobee .changeset .ChangeEntry ;
194import com .github .mongobee .dao .ChangeEntryDao ;
205import com .github .mongobee .exception .MongobeeChangeSetException ;
2611import com .mongodb .MongoClient ;
2712import com .mongodb .MongoClientURI ;
2813import com .mongodb .client .MongoDatabase ;
14+ import org .jongo .Jongo ;
15+ import org .slf4j .Logger ;
16+ import org .slf4j .LoggerFactory ;
17+ import org .springframework .beans .factory .InitializingBean ;
18+ import org .springframework .core .env .Environment ;
19+ import org .springframework .data .mongodb .core .MongoTemplate ;
20+
21+ import java .lang .reflect .InvocationTargetException ;
22+ import java .lang .reflect .Method ;
23+ import java .util .List ;
24+
25+ import static com .mongodb .ServerAddress .defaultHost ;
26+ import static com .mongodb .ServerAddress .defaultPort ;
27+ import static org .springframework .util .StringUtils .hasText ;
2928
3029/**
3130 * Mongobee runner
3635public class Mongobee implements InitializingBean {
3736 private static final Logger logger = LoggerFactory .getLogger (Mongobee .class );
3837
38+ private static final String DEFAULT_CHANGELOG_COLLECTION_NAME = "dbchangelog" ;
39+ private static final String DEFAULT_LOCK_COLLECTION_NAME = "mongobeelock" ;
40+
3941 private ChangeEntryDao dao ;
4042
4143 private boolean enabled = true ;
@@ -47,9 +49,7 @@ public class Mongobee implements InitializingBean {
4749
4850 private MongoTemplate mongoTemplate ;
4951 private Jongo jongo ;
50-
51- private static final String DEFAULT_CHANGELOG_COLLECTION_NAME = "dbchangelog" ;
52- private static final String DEFAULT_LOCK_COLLECTION_NAME = "mongobeelock" ;
52+
5353
5454 /**
5555 * <p>Simple constructor with default configuration of host (localhost) and port (27017). Although
@@ -146,11 +146,11 @@ public void execute() throws MongobeeException {
146146 }
147147
148148 if (!dao .acquireProcessLock ()) {
149- logger .info ("Mongobee did not aqcuire process lock. Exiting." );
149+ logger .info ("Mongobee did not acquire process lock. Exiting." );
150150 return ;
151151 }
152152
153- logger .info ("Mongobee aqcuired process lock, starting the data migration sequence.." );
153+ logger .info ("Mongobee acquired process lock, starting the data migration sequence.." );
154154
155155 try {
156156 executeMigration ();
@@ -337,15 +337,30 @@ public Mongobee setJongo(Jongo jongo) {
337337 this .jongo = jongo ;
338338 return this ;
339339 }
340-
340+
341+ /**
342+ * Overwrites a default mongobee changelog collection hardcoded in DEFAULT_CHANGELOG_COLLECTION_NAME.
343+ * <br/><br/>
344+ * CAUTION! Use this method carefully - when changing the name on a existing system,
345+ * your changelogs will be executed again on your MongoDB instance
346+ *
347+ * @param changelogCollectionName a new changelog collection name
348+ * @return
349+ */
341350 public Mongobee setChangelogCollectionName (String changelogCollectionName ) {
342- this .dao .setChangelogCollectionName (changelogCollectionName );
343- return this ;
351+ this .dao .setChangelogCollectionName (changelogCollectionName );
352+ return this ;
344353 }
345-
354+
355+ /**
356+ * Overwrites a default mongobee lock collection hardcoded in DEFAULT_LOCK_COLLECTION_NAME
357+ *
358+ * @param lockCollectionName a new lock collection name
359+ * @return
360+ */
346361 public Mongobee setLockCollectionName (String lockCollectionName ) {
347- this .dao .setLockCollectionName (lockCollectionName );
348- return this ;
362+ this .dao .setLockCollectionName (lockCollectionName );
363+ return this ;
349364 }
350365
351366 /**
0 commit comments