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

@@ -16,7 +16,7 @@ package com.google.gerrit.server;
import static com.google.gerrit.reviewdb.ApprovalCategory.SUBMIT;
import com.google.gerrit.common.ChangeHookRunner;
import com.google.gerrit.common.ChangeHooks;
import com.google.gerrit.reviewdb.Change;
import com.google.gerrit.reviewdb.ChangeMessage;
import com.google.gerrit.reviewdb.PatchSet;
@@ -216,7 +216,7 @@ public class ChangeUtil {
public static Change.Id revert(final PatchSet.Id patchSetId,
final IdentifiedUser user, final String message, final ReviewDb db,
final RevertedSender.Factory revertedSenderFactory,
final ChangeHookRunner hooks, GitRepositoryManager gitManager,
final ChangeHooks hooks, GitRepositoryManager gitManager,
final PatchSetInfoFactory patchSetInfoFactory,
final ReplicationQueue replication, PersonIdent myIdent)
throws NoSuchChangeException, EmailException, OrmException,
@@ -320,7 +320,7 @@ public class ChangeUtil {
public static void restore(final PatchSet.Id patchSetId,
final IdentifiedUser user, final String message, final ReviewDb db,
final RestoredSender.Factory senderFactory,
final ChangeHookRunner hooks) throws NoSuchChangeException,
final ChangeHooks hooks) throws NoSuchChangeException,
InvalidChangeOperationException, EmailException, OrmException {
final Change.Id changeId = patchSetId.getParentKey();
final PatchSet patch = db.patchSets().get(patchSetId);