Search in sources :

Example 1 with LuceneIndexModuleOnInit

use of com.google.gerrit.pgm.init.index.lucene.LuceneIndexModuleOnInit in project gerrit by GerritCodeReview.

the class BaseInit method createSysInjector.

private Injector createSysInjector(SiteInit init) {
    if (sysInjector == null) {
        final List<Module> modules = new ArrayList<>();
        modules.add(new AbstractModule() {

            @Override
            protected void configure() {
                bind(ConsoleUI.class).toInstance(init.ui);
                bind(InitFlags.class).toInstance(init.flags);
            }
        });
        Injector dbInjector = createDbInjector();
        IndexType indexType = IndexModule.getIndexType(dbInjector);
        if (indexType.isLucene()) {
            modules.add(new LuceneIndexModuleOnInit());
        } else if (indexType.isFake()) {
            try {
                Class<?> clazz = Class.forName("com.google.gerrit.index.testing.FakeIndexModuleOnInit");
                Module indexOnInitModule = (Module) clazz.getDeclaredConstructor().newInstance();
                modules.add(indexOnInitModule);
            } catch (InstantiationException | IllegalAccessException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException e) {
                throw new IllegalStateException("unable to create fake index", e);
            }
            modules.add(new IndexModuleOnInit());
        } else {
            throw new IllegalStateException("unsupported index.type = " + indexType);
        }
        sysInjector = dbInjector.createChildInjector(modules);
    }
    return sysInjector;
}
Also used : LuceneIndexModuleOnInit(com.google.gerrit.pgm.init.index.lucene.LuceneIndexModuleOnInit) Injector(com.google.inject.Injector) ArrayList(java.util.ArrayList) Module(com.google.inject.Module) GerritServerConfigModule(com.google.gerrit.server.config.GerritServerConfigModule) IndexModule(com.google.gerrit.server.index.IndexModule) AbstractModule(com.google.inject.AbstractModule) IndexType(com.google.gerrit.index.IndexType) AbstractModule(com.google.inject.AbstractModule) IndexModuleOnInit(com.google.gerrit.pgm.init.index.IndexModuleOnInit) LuceneIndexModuleOnInit(com.google.gerrit.pgm.init.index.lucene.LuceneIndexModuleOnInit)

Aggregations

IndexType (com.google.gerrit.index.IndexType)1 IndexModuleOnInit (com.google.gerrit.pgm.init.index.IndexModuleOnInit)1 LuceneIndexModuleOnInit (com.google.gerrit.pgm.init.index.lucene.LuceneIndexModuleOnInit)1 GerritServerConfigModule (com.google.gerrit.server.config.GerritServerConfigModule)1 IndexModule (com.google.gerrit.server.index.IndexModule)1 AbstractModule (com.google.inject.AbstractModule)1 Injector (com.google.inject.Injector)1 Module (com.google.inject.Module)1 ArrayList (java.util.ArrayList)1