Only bind index {start/activate} if needed

These commands are only interacting with the AbstractVersionManager, if
it is not available then they have no reason to be available.

Because those commands were always binded, binding an implementation of
AbstractVersionManager was mandatory otherwise Guice would have
complained. For that reason, the implementation of
AbstractVersionManager was done even in the case when index is a single
version and an implementation of AbstractVersionManager is not required.
Only bind implementations of AbstractVersionManager when needed and bind
the commands only if AbstractVersionManager implementation is binded.

Change-Id: I3db48f6b5d030ecc6efa840c59eb4e177ae1b6b1
This commit is contained in:
Hugo Arès
2018-04-10 15:24:26 -04:00
parent 52c2b4afe0
commit 37d47e9c6e
5 changed files with 17 additions and 6 deletions

View File

@@ -64,11 +64,11 @@ public class ElasticIndexModule extends LifecycleModule {
install(new IndexModule(threads));
if (singleVersions == null) {
bind(AbstractVersionManager.class).to(ElasticVersionManager.class);
listener().to(ElasticVersionManager.class);
} else {
install(new SingleVersionModule(singleVersions));
}
bind(AbstractVersionManager.class).to(ElasticVersionManager.class);
}
@Provides