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

@@ -14,7 +14,7 @@
package com.google.gerrit.server.patch;
import com.google.gerrit.common.ChangeHookRunner;
import com.google.gerrit.common.ChangeHooks;
import com.google.gerrit.common.data.ApprovalType;
import com.google.gerrit.common.data.ApprovalTypes;
import com.google.gerrit.reviewdb.ApprovalCategory;
@@ -67,7 +67,7 @@ public class PublishComments implements Callable<VoidResult> {
private final PatchSetInfoFactory patchSetInfoFactory;
private final ChangeControl.Factory changeControlFactory;
private final FunctionState.Factory functionStateFactory;
private final ChangeHookRunner hooks;
private final ChangeHooks hooks;
private final PatchSet.Id patchSetId;
private final String messageText;
@@ -86,7 +86,7 @@ public class PublishComments implements Callable<VoidResult> {
final PatchSetInfoFactory patchSetInfoFactory,
final ChangeControl.Factory changeControlFactory,
final FunctionState.Factory functionStateFactory,
final ChangeHookRunner hooks,
final ChangeHooks hooks,
@Assisted final PatchSet.Id patchSetId,
@Assisted final String messageText,