Refactor ChangeHookRunner as an interface

This enables deciding at startup time if hooks will be supported,
and if not stub in a dummy implementation that does nothing. This
is mainly useful for my gerrit-review.googlesource.com environment
where the standard hook system of spawning an external program is
not supportable.

The factoring is a simple step towards a more pluggable event system.
Someone could implement a new version of ChangeHooks that uses a
Guice multibinding to dispatch these events to multiple instances
of the ChangeHooks API.

Change-Id: I6e9fba78f87d6e9ba8aaf80d386230334a492ea2
This commit is contained in:
Shawn O. Pearce
2012-01-23 11:28:42 -08:00
parent d6bd00b5eb
commit 8dba895ad6
18 changed files with 249 additions and 95 deletions

View File

@@ -17,6 +17,7 @@ package com.google.gerrit.httpd;
import static com.google.inject.Scopes.SINGLETON;
import static com.google.inject.Stage.PRODUCTION;
import com.google.gerrit.common.ChangeHookRunner;
import com.google.gerrit.lifecycle.LifecycleManager;
import com.google.gerrit.lifecycle.LifecycleModule;
import com.google.gerrit.server.config.AuthConfigModule;
@@ -184,6 +185,7 @@ public class WebAppInitializer extends GuiceServletContextListener {
private Injector createSysInjector() {
final List<Module> modules = new ArrayList<Module>();
modules.add(new WorkQueue.Module());
modules.add(new ChangeHookRunner.Module());
modules.add(cfgInjector.getInstance(GerritGlobalModule.class));
modules.add(new SmtpEmailSender.Module());
modules.add(new SignedTokenEmailTokenVerifier.Module());