Prevent circular module dependency when running in external container

Commit 220a3f5 introduced circular dependency between the database
module and NotesMigration (impl. class ConfigNotesMigration).

Having the site path being stored in the database was broken by above
change. The class Daemon solves this by explicitly setting the site
path and adds a SitePath module before starting everything.

This patch makes it possible again to run the gerrit war in an external
Servlet container, but you need to set the System property
"-Dgerrit.site_path=/path/to/gerrit" to make it work.

The site path stored in the database became practically obsolete with the
NotesMigration change mentioned above.

Change-Id: Id735fbf928dda186e659792c84d4e675c893a29a
This commit is contained in:
Thomas Meyer
2016-10-25 20:40:02 +02:00
committed by David Pursehouse
parent ee59410153
commit d66f37c5ab

View File

@@ -265,15 +265,7 @@ public class WebAppInitializer extends GuiceServletContextListener
listener().to(ReviewDbDataSourceProvider.class);
}
});
}
modules.add(new DatabaseModule());
modules.add(new DropWizardMetricMaker.ApiModule());
return Guice.createInjector(PRODUCTION, modules);
}
private Injector createCfgInjector() {
final List<Module> modules = new ArrayList<>();
if (sitePath == null) {
// If we didn't get the site path from the system property
// we need to get it from the database, as that's our old
// method of locating the site path on disk.
@@ -287,8 +279,15 @@ public class WebAppInitializer extends GuiceServletContextListener
});
modules.add(new GerritServerConfigModule());
}
modules.add(new SchemaModule());
modules.add(new DatabaseModule());
modules.add(new ConfigNotesMigration.Module());
modules.add(new DropWizardMetricMaker.ApiModule());
return Guice.createInjector(PRODUCTION, modules);
}
private Injector createCfgInjector() {
final List<Module> modules = new ArrayList<>();
modules.add(new SchemaModule());
modules.add(SchemaVersionCheck.module());
modules.add(new AuthConfigModule());
return dbInjector.createChildInjector(modules);