Introduce CacheImpl annotation

There is existing mechanism to provide different implementation for
instance to secure-store but one can replace only certain binding
with it (through provider class). In this case when H2CacheImpl is
installed it adds more bindings and replacing only this class would
keep leftovers being still initiated/running in Gerrit core.

CacheImpl annotation contains 2 types:
MEMORY
PERSISTENT
It is applied to modules that provide corresponding default caches
implementations.

When CacheImpl annotation is added to lib module then it will
override particular default implementation.

Change-Id: I7562b210fad4c5f6dc67887f627cf76815a378cb
Signed-off-by: Jacek Centkowski <jcentkowski@collab.net>
This commit is contained in:
Jacek Centkowski
2018-05-08 19:04:06 +02:00
committed by David Pursehouse
parent e602b8dacc
commit 5517ec316f
5 changed files with 108 additions and 4 deletions

View File

@@ -34,6 +34,7 @@ import com.google.gerrit.pgm.util.LogFileCompressor;
import com.google.gerrit.server.LibModuleLoader;
import com.google.gerrit.server.StartupChecks;
import com.google.gerrit.server.account.InternalAccountDirectory;
import com.google.gerrit.server.cache.CacheOverrides;
import com.google.gerrit.server.cache.h2.DefaultCacheFactory;
import com.google.gerrit.server.change.ChangeCleanupRunner;
import com.google.gerrit.server.config.AuthConfig;
@@ -364,8 +365,8 @@ public class WebAppInitializer extends GuiceServletContextListener implements Fi
});
modules.add(new GarbageCollectionModule());
modules.add(new ChangeCleanupRunner.Module());
modules.addAll(LibModuleLoader.loadModules(cfgInjector));
return cfgInjector.createChildInjector(modules);
return cfgInjector.createChildInjector(
CacheOverrides.override(modules, LibModuleLoader.loadModules(cfgInjector)));
}
private Module createIndexModule() {